views:

175

answers:

1

Does session_unset() unregister all the $_SESSION vars, or do you have to manually clear each variable registered into the $_SESSION array with unset() ?

I'm confused about this because the PHP documentation says:

Only use session_unset() for older deprecated code that does not use $_SESSION.

If $_SESSION is used, use unset() to unregister a session variable

+4  A: 

Yes it removes all sessions vars.

session_unset — Free all session variables

www.php.net

To remove all session vars, you can also use:

session_destroy();

Sometimes you might have problems even if using both session_unset and session_destroy. You have to clear $_SESSION array.

session_unset();
session_destroy();
$_SESSION = array();
Sarfraz