Home  >  Article  >  Backend Development  >  session_unset() and session_destroy() usage analysis_PHP tutorial

session_unset() and session_destroy() usage analysis_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:02:45801browse

Introducing the use of session_unset() and session_destroy() functions.

session_unset()
Release all $_SESSION variables currently created in memory, but do not delete the session file and do not release the corresponding session
id

session_destroy()
Delete the session file corresponding to the current user and release the session
id, the contents of the $_SESSION variable in memory are still retained

if (session_destroy())
           {
ShowMsg("Logout successful!",'/member/login');
exit();
}
        else
           {
              unset($_SESSION);
ShowMsg("Logout successful!",'/member/login');
exit();
}


Therefore, to release all resources of the user's session, the following code needs to be executed in sequence:
Program code

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