note 83963 deleted from function.session-write-close by googleguy

From: Date: Tue, 22 Oct 2013 11:01:27 +0000
Subject: note 83963 deleted from function.session-write-close by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197026@lists.php.net to get a copy of this message
Note Submitter: lee ---- It seems that the session data is written out when there is actual changes to the array. class Login(){ function logoff(){ session_unset(); @session_destroy(); @session_start(); $_SESSION = array(); session_commit(); } } //during test, this doesn't work and the session data remain. classLoginObject->logoff(); //I fix it like this class Login(){ function logoff(){ session_unset(); @session_destroy(); @session_start(); $_SESSION = array(); $_SESSION['cleardata'] = 1; <------ unset($_SESSION['cleardata']);<------ session_commit(); } } //after the fix, this works and the session is empty. classLoginObject->logoff(); I was using phpunit(Sebastian Bergmann) to do my test.

« previous php.notes (#197026) next »