PHP中的session_unset()和session_destroy()有什么区别? [英] What is the difference between session_unset() and session_destroy() in PHP?

查看:109
本文介绍了PHP中的session_unset()和session_destroy()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

php.net 文档中:

session_destroy -销毁所有数据注册到会话

session_destroy — Destroys all data registered to a session

session_unset -释放所有会话变量

session_unset — Free all session variables

我的三部分问题是:

这两个功能看起来非常相似.
两者之间到底有什么区别?

The two functions seem very similar.
What is really the difference between the two?

两个似乎都删除了注册到会话的所有变量.它们中的任何一个是否实际上破坏了会话本身?如果没有,您如何完成此操作(销毁会话本身).

Both seem to delete all variables registered to a session. Does any of them actually destroy the session itself? If not, how do you accomplish this (destroy the session itself).

两个函数都没有删除客户端的会话cookie是否正确?

Is it correct that neither of the two functions deletes the session cookie at the client?

推荐答案

session_unset 仅清除$_SESSION变量.等效于:

session_unset just clears the $_SESSION variable. It’s equivalent to doing:

$_SESSION = array();

因此,这只会影响本地$_SESSION变量实例,而不会影响会话存储中的会话数据.

So this does only affect the local $_SESSION variable instance but not the session data in the session storage.

与此相反, session_destroy 破坏了存储的会话数据在会话存储中(例如文件系统中的会话文件).

In contrast to that, session_destroy destroys the session data that is stored in the session storage (e.g. the session file in the file system).

其他所有内容保持不变.

Everything else remains unchanged.

这篇关于PHP中的session_unset()和session_destroy()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆