note 46337 deleted from function.session-destroy by googleguy

From: Date: Fri, 14 Sep 2012 05:23:02 +0000
Subject: note 46337 deleted from function.session-destroy by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190749@lists.php.net to get a copy of this message
Note Submitter: thomas at uninet dot se ---- I did encounter a minor problem when I tried to remove the physical file that stores the session. The problem was that my working directory wasn't on the same drive as my PHP installation (yes, I used Windows). So I used the PHP_BINDIR to start at the same place as PHP does and then change directory to the place that was specified in PHP.INI. This makes it transparent to relative paths in session.save_path. <?php function DeleteSessionID($sessionid) { $orgpath = getcwd(); chdir(PHP_BINDIR); chdir(session_save_path()); $path = realpath(getcwd()).'/'; if(file_exists($path.'sess_'.$sessionid)) { // Delete it here unlink($path.'sess_'.$sessionid); } else { // File not found } chdir($orgpath); } ?> The final chdir($orgpath) is just to restore the working directory as it were before .

« previous php.notes (#190749) next »