i need help with sessions and logging out. i use the '$_SESSION....' stuff. and to try and logout i use 'session_destroy()' which is activated when a user clicks the link 'logout'. I get an error and idk what to do. the error is Warning: Trying to destroy uninitialized session in c:\program files\easyphp\www\medieval\logout.php on line 4'just a shot.....make sure u have somethin like this in logout.php
<?
session_start();
session_destroy();
echo 'you have been successfully logged out';
?>alright, thanks it worked. that was sure easy.Be warned though that session_destroy() does exactly that! It destroys the session, it does not clean out the session vars. For that you should do this:
$_SESSION = array();
if you have register_globals Off (default) or
session_unset($foo)
for each session var if register_globals are On.
So your log out function make look something like:
session_destroy();
$_SESSION = array();
<?
session_start();
session_destroy();
echo 'you have been successfully logged out';
?>alright, thanks it worked. that was sure easy.Be warned though that session_destroy() does exactly that! It destroys the session, it does not clean out the session vars. For that you should do this:
$_SESSION = array();
if you have register_globals Off (default) or
session_unset($foo)
for each session var if register_globals are On.
So your log out function make look something like:
session_destroy();
$_SESSION = array();