note 46337 added to function.session-destroy

From: Date: Thu, 07 Oct 2004 15:25:58 +0000
Subject: note 46337 added to function.session-destroy
Groups: php.notes 
Request: Send a blank email to php-notes+get-78138@lists.php.net to get a copy of this message
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 . ---- Manual Page -- http://www.php.net/manual/en/function.session-destroy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46337 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46337&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46337&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78138) next »