We help IT Professionals succeed at work.

php session deletion

hibbsusan
hibbsusan asked
on
Medium Priority
263 Views
Last Modified: 2012-05-12
How come after I run this session and session cookie clearing script (from Murach's php/mysql)

<?php
session_start( );
session_destroy();
$_SESSION = array();
$name = session_name();
$expire = strtotime('-1 year');
$params = session_get_cookie_params();

$path = $params['path'];
$domain = $params['domain'];
$secure = $params['secure'];
$httponly = $params['httponly'];
setcookie($name, '', $expire, $path, $domain, $secure, $httponly);
?>

Open in new window


this code, run immediately afterward:

foreach ($_SESSION as $key=>$val)
{
	echo $key;
	echo '&nbsp; : &nbsp;';
	echo $val;
	echo '<br>';
}

Open in new window


still echos

a  :  asdf

Thank you!
Comment
Watch Question

Author

Commented:
where, of course, before i had set:

$_SESSION['a'] = "asdf";

Open in new window

CERTIFIED EXPERT

Commented:
do:

unset($_SESSION['a']);
and then destroy_session();
CERTIFIED EXPERT

Commented:
err... sorry, session_destroy(); but you already knew that :)
Most Valuable Expert 2011
Author of the Year 2014
Commented:
Please see the logout script in this article.  Please post back if you do not understand it or if you have any questions, thanks. ~Ray
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

Explore More ContentExplore courses, solutions, and other research materials related to this topic.