Created
September 11, 2013 12:08
-
-
Save un1ko85/6522668 to your computer and use it in GitHub Desktop.
delete session file
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 | |
session_start(); // start the current/old session (loads the $_SESSION variables) | |
$base_name = '/sess_'; // the base name for the session data files | |
$old_sessionid = session_id(); // get the current/old id | |
$_SESSION['test'] = 123; // some test data | |
session_regenerate_id(); // generate a new id and a new data file | |
$new_sessionid = session_id(); // get the new session id to store in the user table for the current visitor | |
session_write_close(); // close (release) the old (and the new) session data file (php apparently doesn't close the old file when the id is regenerated) | |
unlink('c:' . ini_get('session.save_path') . $base_name . $old_sessionid); // delete the old session data file | |
session_start(); // restart the current/new session | |
// show the old/new session id | |
echo "Old Session: $old_sessionid<br />"; | |
echo "New Session: $new_sessionid<br />"; | |
print_r($_SESSION); // dump any session data | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment