Thanks for explaining. IOW, if you count the crazy browsers, you
cannot do it with 100% guarantee.

On Sun, Apr 18, 2010 at 1:25 AM, Justin Davis <[email protected]> wrote:
> Nope, if the browser correctly implements cookies then cookies with
> expires equal to an empty string will be deleted when the browser is
> closed.  If an expiration is explicitly defined the cookie is
> considered a persistent cookie and the browser will not delete it
> until the expiration time is hit.
>
> That said, both using an empty expiration time for the cookie and
> setting the 'onunload' both assume that the browser is operating
> normally.
>
> -Justin
>
> On Apr 17, 7:24 am, Branko Vukelic <[email protected]> wrote:
>> Unless they revisit the site in say 23.5 hours, right? That doesn't
>> really count as a "on browser close".
>>
>>
>>
>>
>>
>> On Fri, Apr 16, 2010 at 8:54 PM, Justin Davis <[email protected]> wrote:
>> > The cookie set by sessions expires after "session" (sorry, that's the
>> > way the spec works).  That means that when a user closes their
>> > browser, it will consider the cookie invalid and not send it with the
>> > next request (when the browser is opened again).
>>
>> > The session on disk however (DB, etc) won't be deleted until a user
>> > requests a page and the time between cleanups has been reached
>> > (defaults to 1 day, so not very often).
>>
>> > Basically you shouldn't have to do anything for sessions to go away
>> > after a browser close.
>>
>> > On Apr 16, 4:15 am, Branko Vukelic <[email protected]> wrote:
>> >> I think you could use an XHTTP request to a given page to close your 
>> >> session.
>>
>> >> Basically, you should be able to handle the unload[1] event with
>>
>> >>     window.onunload
>>
>> >> and send the request to your server to kill the session (with the
>> >> cookie contents). If you use HTTPFox or FireBug to check the result of
>> >> the request, you may see that it says "aborted". This usually happens
>> >> because the browser doesn't wait for the response (I'm not really sure
>> >> about this).
>>
>> >> Since closing the browser is an event that happens locally on the
>> >> user's machine, I don't think you can avoid JavaScript. Additionaly,
>> >> you can make the session expire, so if the unload even doesn't get
>> >> handled for some reason, the session expires automatically in, say, 30
>> >> minutes.
>>
>> >> [1]https://developer.mozilla.org/en/DOM/window.onunload
>>
>> >> On Fri, Apr 16, 2010 at 3:07 AM, 江云帆 <[email protected]> wrote:
>> >> > hey, i want to know how to make session expire after user close the web
>> >> > browser
>> >> > this seems need to handle the sockert error at cherryServer to
>> >> > application,is it?
>> >> > any help,welcom
>>
>> >> > --
>> >> > welcom to gtalk me
>> >> >http://hi.baidu.com/jyf1987
>>
>> >> > --
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups
>> >> > "web.py" group.
>> >> > To post to this group, send email to [email protected].
>> >> > To unsubscribe from this group, send email to
>> >> > [email protected].
>> >> > For more options, visit this group at
>> >> >http://groups.google.com/group/webpy?hl=en.
>>
>> >> --
>> >> Branko Vukelić
>>
>> >> Check out my blog:http://www.brankovukelic.com/
>> >> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> >> Registered Linux user #438078 (http://counter.li.org/)
>>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups 
>> >> "web.py" group.
>> >> To post to this group, send email to [email protected].
>> >> To unsubscribe from this group, send email to 
>> >> [email protected].
>> >> For more options, visit this group 
>> >> athttp://groups.google.com/group/webpy?hl=en.
>>
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "web.py" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to 
>> > [email protected].
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/webpy?hl=en.
>>
>> --
>> Branko Vukelić
>>
>> Check out my blog:http://www.brankovukelic.com/
>> Check out my portfolio:http://www.flickr.com/photos/foxbunny/
>> Registered Linux user #438078 (http://counter.li.org/)
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "web.py" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group 
>> athttp://groups.google.com/group/webpy?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web.py" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/webpy?hl=en.
>
>



-- 
Branko Vukelić

Check out my blog: http://www.brankovukelic.com/
Check out my portfolio: http://www.flickr.com/photos/foxbunny/
Registered Linux user #438078 (http://counter.li.org/)

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to