English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I get it so that when the user clicks out of the web browser, the php session is destroyed? When the user logs in the session is created, however when they exit the browser, the session remains although I want it to end.

2007-07-27 05:24:20 · 2 answers · asked by DBap 1 in Computers & Internet Programming & Design

what do u mean by propogated via cookie or url?

2007-07-27 07:14:07 · update #1

All I know is that I do a session_start() and then I use $_SESSION['username']. Is that using urls or a cookie?

2007-07-27 07:19:28 · update #2

2 answers

Depends on how the session is propagated.

If it is propagated via URLs, there is no way to end the session immediately after the browser is closed; the session ID will remain active for the number of seconds set by the session.gc_maxlifetime directive in php.ini.

If the session is propagated via cookies, you need to set session.cookie_lifetime = 0 in your php.ini.

You can also implement an explicit logout procedure, during which you unset all session variables:

foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}

2007-07-27 06:09:48 · answer #1 · answered by NC 7 · 1 0

session_destroy() ;

2007-07-27 05:32:19 · answer #2 · answered by mtlboy84 1 · 0 0

fedest.com, questions and answers