$_SESSION[] problems
Moderator: General Moderators
$_SESSION[] problems
Hi, I'm writing a login script that uses a session variable to remember authenticated users. The problem is that I want the session to die when the browser is closed, but it doesn't. It used to erase the session when the browser was closed but then for no apparent reason it stopped working. I was under the impression that the default for session variables is to erase when the browser is closed but mine arn't erased. Is there any way to kill the session variable when the browser is closed?
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: $_SESSION[] problems
SESSIONS are cleared after certain time passes, this configuration is saved in apache configuration(i think), there is a PHP function to set this time limit namely "session_cache_expire". As for the catching the event in window close, i don;t think there is any such javascript that does it, apparently they didn't put this function because they thought someone would do like this
if (close my window event)
{
don't close the window
;
}
humm makes sense why they didn't make catching window close event, doesn't it?
if (close my window event)
{
don't close the window
}
humm makes sense why they didn't make catching window close event, doesn't it?
Re: $_SESSION[] problems
You can try cookies. At the time of creating cookies don't set its time. The cookie will be deleted with the close of browser.
ie
cookie can be set in this way:
setcookie("cookiename",$value, time()+3600*24);
but for you requirement use only:
setcookie("cookiename",$value);
ie
cookie can be set in this way:
setcookie("cookiename",$value, time()+3600*24);
but for you requirement use only:
setcookie("cookiename",$value);
Re: $_SESSION[] problems
Session variables are kept on the server, so the server has no way to know that a viewer has closed their browser or browsed to a different page or even died at the keyboard.
Re: $_SESSION[] problems
https://developer.mozilla.org/En/DOM/Wi ... foreunloadnovice4eva wrote:As for the catching the event in window close, i don;t think there is any such javascript that does it, apparently they didn't put this function because they thought someone would do like this
if (close my window event)
{
don't close the window;
}
humm makes sense why they didn't make catching window close event, doesn't it?
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: $_SESSION[] problems
weeeeeeee
mmj thanks for that link