Page 1 of 1

Session End

Posted: Fri Oct 17, 2003 11:54 am
by AliasBDI
I am making a logout page and I need to close a session. I tried using "session_unregister();" but it gives me this error:
Wrong parameter count for session_unregister()
Any ideas why?

Posted: Fri Oct 17, 2003 11:59 am
by markl999
If you're using PHP >= 4.1.0 then don't use session_register/unregister, use $_SESSION.

E.g.

Code: Select all

session_start();
if(!isset($_SESSION['foo'])){
    $_SESSION['foo'] = 'hello';
}
echo $_SESSION['foo'];
And to unset/unregister

Code: Select all

unset($_SESSION['foo']); //to just unset 'foo'
session_destroy(); //unset all session variables

//if you have register_globals On, which you shouldn't have...
$foo = '';
unset($_SESSION['foo']);

Posted: Sun Oct 19, 2003 11:51 am
by richie256
I prefer to use this one:

Code: Select all

<?php
session_start(); 
session_destroy(); 
$_SESSION = array(); 

?>