Jump to content

delete session cookie on browser close?


nibblebot

Recommended Posts

I'm trying to end the sessions on my site when a user closes their UA.

I have session.cookie_lifetime = 0 (the default).

http://us3.php.net/manual/en/ref.session.php says:

session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.

Shouldn't the cookie get deleted on browser close? As it stands it does not. I can provide other config variables if someone has an idea why this doesn't work.

TIA, joshua.

Link to comment
Share on other sites

I'm trying to end the sessions on my site when a user closes their UA.

I have session.cookie_lifetime = 0 (the default).

http://us3.php.net/manual/en/ref.session.php says:

session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.

Shouldn't the cookie get deleted on browser close? As it stands it does not. I can provide other config variables if someone has an idea why this doesn't work.

TIA, joshua.

 

Well, the browsers are supposed to delete the cookie when they close/leave the site.

 

I don't really know ajax, but maybe you can run a script that will destroy the session every time the onClose event occurs?

 

Orio.

Link to comment
Share on other sites

The session will end, as in if the user closed the browser and re-opened it, they would get a new session.

 

But the session on the server side will remain until the GC runs.

 

This is the expected behavior. However, if I restart the browser, the cookie with the SID still remains.

I'd prefer not to use any javascript to solve this. Do you think Firefox (the browser I'm testing with) refuses to delete the cookie?

I have it set to delete cookie 'when it expires' in my Firefox settings.

Any ideas?

Link to comment
Share on other sites

Just use a session_destroy in yer php code, when yer done with it.

 

at the start of code, maybe ya can use a cookie, to dictate if there is an active session,

 

if(isset($_COOKIE['us']) && !empty($_COOKIE['us'])) 
{
    $use_sessions=true;
    start_sessions();
}

 

this will give ya use of the sessions, if that cookie is set

when ya done with the session support

setcookie('us','');
destroy_session();

 

now ya just need a place of when the cookie is set :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.