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] Link to comment https://forums.phpfreaks.com/topic/29192-sessions/ 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. Link to comment https://forums.phpfreaks.com/topic/29192-sessions/#findComment-133839 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] Link to comment https://forums.phpfreaks.com/topic/29192-sessions/#findComment-133843 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] Link to comment https://forums.phpfreaks.com/topic/29192-sessions/#findComment-133845 Share on other sites More sharing options...
Iryk Posted December 2, 2006 Author Share Posted December 2, 2006 That didnt work either :( Link to comment https://forums.phpfreaks.com/topic/29192-sessions/#findComment-133850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.