note 84534 added to function.session-destroy

From: Date: Thu, 17 Jul 2008 20:19:08 +0000
Subject: note 84534 added to function.session-destroy
Groups: php.notes 
Request: Send a blank email to php-notes+get-141636@lists.php.net to get a copy of this message
<?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. } } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 216.244.35.209 ---- Manual Page -- http://www.php.net/manual/en/function.session-destroy.php Edit -- https://master.php.net/note/edit/84534 Del: integrated -- https://master.php.net/note/delete/84534/integrated Del: useless -- https://master.php.net/note/delete/84534/useless Del: bad code -- https://master.php.net/note/delete/84534/bad+code Del: spam -- https://master.php.net/note/delete/84534/spam Del: non-english -- https://master.php.net/note/delete/84534/non-english Del: in docs -- https://master.php.net/note/delete/84534/in+docs Del: other reasons-- https://master.php.net/note/delete/84534 Reject -- https://master.php.net/note/reject/84534 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141636) next »