manick Posted April 23, 2006 Share Posted April 23, 2006 Can anybody please tell me where I am going wrong, I am trying to set a cookie on a flash intro page to basically say if I have been here before, go straight to the main.html page.As ever, any help much appreciated!!function chkcook(){ if (document.cookie.beenbefore !='TRUE'){ }else { window.location="main.html"; return false } //stop hiding--> </script> <script > <!--hide function previousCookie (name, value) { // number of days the cookie should last var expDays = 180; var exp = new Date(); exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000)); expirationDate = exp.toGMTString(); // Set cookie with name and value provided // in function call and date from above document.cookie = name + '=' + escape(value) document.cookie += '; expires=' + exp.toGMTString();}I AM THEN TRYING TO CALL THEM WITH THE FOLLOWING:<<body onload="SetCookie('wishlist',cookieString)";"chkcook()";"onblur="previouscookie('beenbefore','TRUE')";>Many thanksNick Trenam Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 23, 2006 Share Posted April 23, 2006 if (document.cookie.beenbefore !='TRUE'){I'm pretty sure you can't access a cookie like that. You'd have to find the appropriate variable in document.cookie using indexOf and substring, and then substring that to get the variable. The correct code is displayed in the W3S cookie example. :)Choco Link to comment Share on other sites More sharing options...
manick Posted April 24, 2006 Author Share Posted April 24, 2006 Thanks I'll look into itNick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now