Page 1 of 1
session_unregister() dies
Posted: Fri Jun 18, 2004 11:45 am
by evilregis
Code: Select all
else if( $_GETї'action'] == 'logout' )
{
if(session_is_registered('username'))
{
//session variable is unregistered, the user is ready to logout
session_unregister() or die('sessions not unset');
session_destroy() or die('sessions not destroyed');
}
//session information is gone, display login
showForm();
exit;
}
New to PHP, just trying to get a grip on sessions/authentication using mySQL/PHP together. I have a logout button that, when pressed, I'd like to kill the current session. This is the code for the logout action. However, the session_unregister() dies and the session remains. If I were to go back to the original page it lets me in no problem. Any ideas?
Posted: Fri Jun 18, 2004 11:53 am
by feyd
php manual :: session_unregister() wrote:Note: If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use [php_man]unset[/php_man]() to unregister a session variable. Do not [php_man]unset[/php_man]() $_SESSION itself as this will disable the special function of the $_SESSION superglobal.
and later
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use [php_man]session_register[/php_man](), [php_man]session_is_registered[/php_man]() and [php_man]session_unregister[/php_man]().