开发者

PHP - Does session_unset unregister $_SESSION vars?

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


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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜