note 84534 deleted from function.session-destroy by googleguy

From: Date: Fri, 14 Sep 2012 05:19:28 +0000
Subject: note 84534 deleted from function.session-destroy by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190745@lists.php.net to get a copy of this message
Note Submitter: iam4webwork at hotmail dot com ---- <?php session_name("PeekABook"); /** * * Assuming that we resume a session already underway * with a specified session name, over-riding * the default provided in php.ini: session.name * **/ session_start(); /** * If you only wish to nullify all of the session variables. * **/ $_SESSION = array(); /** * read and save session name to later void session * cookie * **/ $session_name = session_name(); /** * destroy session data. * no need to use session_unset() in PHP5 **/ session_destroy(); /** * If you wish to kill the session, then you must * delete the session cookie. * An http request is needed to effectively * set the cookie to permanent inactive status; * only the browser can remove the cookie. * **/ if ( isset( $_COOKIE[ $session_name ] ) ) { if ( setcookie(session_name(), '', time()-3600, '/') ) { header("Location: http://localhost/some_other_page.php"); exit(); } else { // setcookie() fails when there is output sent prior to calling this function. } } ?>

« previous php.notes (#190745) next »