carefree Posted September 19, 2007 Share Posted September 19, 2007 I want to creat a javascriipt that uses cookies to redirect a signup page. Basicly i can put this into my template and wherever a user enters the site they get redirected to the url. I have this at the moment it works great but i need it so it goes to a html page and not a popup as it is now: <!-- function ScanCookie(variable) { cook = document.cookie; variable += "="; place = cook.indexOf(variable,0); if (place <= -1) return("0" ); else { end = cook.indexOf(";",place) if (end <= -1) return(unescape(cook.substring(place+variable.length,cook.length))); else return(unescape(cook.substring(place+variable.length,end))); } } function CreationCookie(nom,valeur,permanent) { if(permanent) { dateExp = new Date(2020,11,11); dateExp = dateExp.toGMTString(); ifpermanent = '; expires=' + dateExp + ';'; } else ifpermanent = ''; document.cookie = nom + '=' + escape(valeur) + ifpermanent; } if(ScanCookie("dejapopup" )==0) { var msg="Please sign confirm entry" if(confirm(msg)) CreationCookie("dejapopup","oui",false) else window.location.replace('http://www.SITE.com/signup.html'); } //--> Thanks Link to comment https://forums.phpfreaks.com/topic/69889-cookie-redirect/ Share on other sites More sharing options...
Stickybomb Posted September 25, 2007 Share Posted September 25, 2007 instead of using window.location you can write a meta redirect document.write("<meta http-equiv='refresh' content='5;url=http:www.yoursite.com' />"); as long as this is run in the head it should work fine. however if you are want to work with cookies i would suggest using php its alot simpler to use and work with cookies Link to comment https://forums.phpfreaks.com/topic/69889-cookie-redirect/#findComment-355109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.