Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

cwesty

macrumors member
Original poster
Oct 22, 2005
50
0
Hello all.

I am trying to set a cooie and have it called once the page is opened...

the function i've used is:

function setCookie() {
document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString(value)
}

which is stored in a seperate .js file.

On the index page, there is the following embedded in the html:


<script language="javascript" type="text/javascript">

setCookie();

</script>

For some reason, no cookie is being set, and wasn't sure why...

any thoughts?
 
What is the variable value? are you setting that elsewhere? I don't think you actually need that there at all. Also, is the external javascript file loaded before you run the inline setCookie()?
 
Many browsers have an option where you can turn off the option to accept cookies. Easy to check...

-T
 
What is the variable value? are you setting that elsewhere? I don't think you actually need that there at all. Also, is the external javascript file loaded before you run the inline setCookie()?


it's:


now = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)
lastVisit = new Date(cookieVal("pageVisit"))
document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.