Home  >  Article  >  php教程  >  session_unset()和session_destroy()用法分析

session_unset()和session_destroy()用法分析

WBOY
WBOYOriginal
2016-06-13 11:18:531363browse

 

关于session_unset()和session_destroy()的函数使用进行介绍。

session_unset()
释放当前在内存中已经创建的所有$_SESSION变量,但不删除session文件以及不释放对应的session
id

session_destroy()
删除当前用户对应的session文件以及释放session
id,内存中的$_SESSION变量内容依然保留

if (session_destroy())
        {
            ShowMsg("注销成功!",'/member/login');
            exit();
        }
        else
        {
            unset($_SESSION);
            ShowMsg("注销成功!",'/member/login');
            exit();
        }


因此,释放用户的session所有资源,需要顺序执行如下代码:
程序代码

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn