Deleting a session value can use PHP's unset function, which is removed from the global variable $_session and cannot be accessed.
Session_Start (); $_session[' name '] = ' jobs '; unset ($_session[' name '); Echo $_session[' name ']; Hint name does not exist
If you want to delete all sessions, you can use the Session_destroy function to destroy the current Session,session_destroy delete all data, but session_id still exists.
Session_Start (); $_session[' name '] = ' jobs '; $_session[' time ' = time (); Session_destroy ();
It is important to note that Session_destroy does not immediately destroy the value in the global variable $_session, but only when the next time it is accessed, $_session is empty, so if you need to destroy $_session immediately, you can use the unset function.
Session_Start (); $_session[' name '] = ' jobs '; $_session[' time ' = time (); unset ($_session); Session_destroy (); Var_dump ($_session); This is now empty
If it is necessary to destroy the session_id in the cookie at the same time, usually when the user exits, it is also necessary to explicitly call the Setcookie method to remove the session_id cookie value.
Task
Use unset to remove the session value for name.
<? PHP Session_Start (); $_session [' name '] = ' jobs '; // Delete the session value of name here unset ($_session[' name ']); if (isset($_session[' name ')]) { echo$_session[' name '] ]; return ;} Echo ' Session is destroyed ';
PHP Learning Note: Delete and destroy session