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