session_unregister() dies

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
evilregis
Forum Newbie
Posts: 1
Joined: Fri Jun 18, 2004 11:45 am

session_unregister() dies

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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]().
Post Reply