Trouble with sessions
Here is something very strange I have noticed about PHP.
I now know you don't need to call global $_SESSION to get ahold of session data inside a function, but I wasn't sure at the time, so I threw it in anyway. However, doing this will kill your sessions. Kill them dead.
This code will spit out the current time everytime you hit reload because nothing will stick in the session. If you remove the global statement, it will spit out the time you first loaded the page everytime you hit reload.
I now know you don't need to call global $_SESSION to get ahold of session data inside a function, but I wasn't sure at the time, so I threw it in anyway. However, doing this will kill your sessions. Kill them dead.
function logout() {
global $_SESSION;
}
session_start();
logout();
if(!$_SESSION['time']) {
$_SESSION['time'] = time();
}
echo $_SESSION['time'];This code will spit out the current time everytime you hit reload because nothing will stick in the session. If you remove the global statement, it will spit out the time you first loaded the page everytime you hit reload.
