note 26966 added to function.session-get-cookie-params

From: Date: Tue, 19 Nov 2002 05:35:30 +0000
Subject: note 26966 added to function.session-get-cookie-params
Groups: php.notes 
Request: Send a blank email to php-notes+get-39679@lists.php.net to get a copy of this message
This function is quite handy when it comes to expiring session cookies... since Session cookies don't automatically get destroyed (see the session_destroy page). For instance, here's what I plan to use to expire session cookies: $CookieInfo = session_get_cookie_params(); if ( (empty($CookieInfo['domain'])) && (empty($CookieInfo['secure'])) ) { setcookie(session_name(), '', time()-3600, $CookieInfo['path']); } elseif (empty($CookieInfo['secure'])) { setcookie(session_name(), '', time()-3600, $CookieInfo['path'], $CookieInfo['domain']); } else { setcookie(session_name(), '', time()-3600, $CookieInfo['path'], $CookieInfo['domain'], $CookieInfo['secure']); } session_destroy(); It doesn't check to see if the path part of the session cookie is set because the defaults in php.ini have this set already, unlike domain and secure. -- http://www.php.net/manual/en/function.session-get-cookie-params.php http://master.php.net/manage/user-notes.php?action=edit+26966 http://master.php.net/manage/user-notes.php?action=delete+26966 http://master.php.net/manage/user-notes.php?action=reject+26966

« previous php.notes (#39679) next »