Jump to content

Sessions


Iryk

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.