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
Hi all, any one got 2 mins to help with this?

Javascript to set a cookie =


<!-- Hide script from older browsers

now = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)
lastVisit = new Date(cookieVal("pageVisit"))
document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString();



function cookieVal(cookieName) {
pageVisit = document.cookie.split("; ")
for (i=0; i<pageVisit.length; i++) {
if (cookieName == pageVisit.split("=")[0]) {
return pageVisit.split("=")[1]
}
}
return "1 January 1970"
}



function newCheck(yyyy,mm,dd) {
lastChgd = new Date(yyyy,mm-1,dd)

if (lastChgd.getTime() > lastVisit.getTime()) {
document.write("<a href='main.html'>Enter The Site</a>")
}
}

else {
window.location=("main.html")


}

Within my html file i have the following:

<script language="javascript" type="text/javascript">
<!-- Hide script from older browsers

newCheck(2007,2,21)

// End hiding script -->
</script>

Any ideas why this isn't writing the cookie to the computer?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.