Last active
April 20, 2017 14:34
-
-
Save miclaus/9d9afe9f0128df731b907660ee2320a9 to your computer and use it in GitHub Desktop.
Kills PHP session.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// NOTE: see http://www.php.net/manual/en/function.session-destroy.php | |
function session_kill() { | |
// Unset all of the session variables. | |
session_unset(); | |
// $_SESSION = []; | |
// If it's desired to kill the session, also delete the session cookie. | |
// Note: This will destroy the session, and not just the session data! | |
if ( ini_get('session.use_cookies')) { | |
$params = session_get_cookie_params(); | |
setcookie(session_name(), '', time() - 42000, | |
$params['path'], $params['domain'], | |
$params['secure'], $params['httponly'] | |
); | |
} | |
// Finally, destroy the session. | |
session_destroy(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment