Iryk Posted December 2, 2006 Share Posted December 2, 2006 I am trying to make a session/cookie that will last until the next day (ie. if is Mon. then it expires on Tue). But everytime the page is visited the script doesn't create a cookie. I am have checked and made sure I had cookies enabled and everything. Please Help![code]<?if($setCookie == "yes") { setcookie('adventCalendar', doNotWarn, time()+1); header("Location: http://neopets.com/winter/adventcalendar.phtml");} else { if(!isset($_COOKIE["adventCalendar"])) { echo '<a href="adventCalendar.php?setCookie=yes"><font color="red">Advent Calendar</font></a><br>'; } else { echo '<a href="http://neopets.com/winter/adventcalendar.phtml"><font color="green">Advent Calendar</font></a><br>'; }}echo $_COOKIE["adventCalendar"];?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted December 2, 2006 Share Posted December 2, 2006 More than likely because you are setting the cookie to expire in 1 second from the time it is created. Quote Link to comment Share on other sites More sharing options...
Iryk Posted December 2, 2006 Author Share Posted December 2, 2006 OH yeah... lol... Well I fixed that... Now its not reading the COOKIE. Also is it possible to use the date() function instead of the time()?[code]<?if($setCookie == "yes") { setcookie(adventCalendar, doNotWarn, time() + 3600); header("Location: http://neopets.com/winter/adventcalendar.phtml");} else { if(isset($_COOKIE['adventCalendar'])) { echo '<font color="green">Advent Calendar</font><br>'; } else { echo '<a href="adventCalendar.php?setCookie=yes"><font color="red">Advent Calendar</font></a><br>'; }}?>[/code] Quote Link to comment Share on other sites More sharing options...
fert Posted December 2, 2006 Share Posted December 2, 2006 replace[code]setcookie(adventCalendar, doNotWarn, time() + 3600);[/code][code]setcookie("adventCalender","doNotWarn",time()+3600,"www.domain.com","/",0);[/code] Quote Link to comment Share on other sites More sharing options...
Iryk Posted December 2, 2006 Author Share Posted December 2, 2006 That didnt work either :( Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.