4 个简单的 PHP 会话问题

4 Simple PHP Session Questions

1) session_unset(); 具体是做什么的? & session_destroy();做什么?

2) 我需要同时拥有它们吗?

3) 他们是删除每个登录用户的所有会话,还是只删除访问包含此 php 页面的用户?

4) 会话的默认超时是多少?

简单的答案,来自文档

session_unset():

The session_unset() function frees all session variables currently registered.

session_destroy():

session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.

在某些情况下,是的,您应该同时使用它们。

它似乎只会 unset/destroy 当前会话,即个人用户的会话。

默认超时为1440 seconds