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

cwesty

macrumors member
Original poster
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()?
 
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.