Just use unset to undo any array index. And the session itself is an array. So use unset to disable your specific session index. You are mistaken in the case of the session_unset and session_destroy functions, because they do not accept any parameters.
It should also be noted that you should not use session_destroy , as it will disconnect all available sessions. E.g. when you exit the system, you may not want to lose your products in the basket formed by the session.
Edit
session_destroy — Destroys all data registered to a session
session_unset — Frees all session variables
session_unset just clears the $ _SESSION variable. Its equivalent:
$_SESSION = array(); Thus, this only affects the local instance of the $ _SESSION variable, and not the session data in the session store.
In contrast, session_destroy destroys session data that is stored in the session store (for example, a session file in the file system).
Everything else remains unchanged.
source share