PHP Sessions all delete at the same time:
PHP Code:
session_start(); // essential
$_SESSION['date'] = time(); //find out date with mktime()
$_SESSION['day'] = date('l'); //date, for example "Sunday"
These will both end at the same time. Now, perhaps we want one to end before the session is closed, we will use unset(), unset() unsets a variable.
PHP Code:
session_start(); // essential
$_SESSION['date'] = time(); //find out date with mktime()
$_SESSION['day'] = date('l'); //date, for example "Sunday"
if($_SESSION['day'] == "Wednesday") { //if the day equals wednesday
unset($_SESSION['day']); //unset it
}
if(isset($_SESSION['day'])){ //if the say session exists
echo "Today isn't Wednesday";
}
else { //if it doesn't
echo "Today is Wednesday";
}
This is just an example of a session ending earlier then another.
Bookmarks