end session when the browser window is closed.

G

Guest

I want to do clean up routine to my database when the browser is closed. I
have my code in session-end - but it never fires when the browser closes. I
cant do onbeforeunload as it will be fired each time when the browser posts
back.
Somehow I want to capture browser close event and fire session abandon which
will call session end. Please help.
Thanks,
Sun
 
J

James Steele

Hi Sun,

I don't beleive you can "reliably detect" a browser closing.
Have you tried employing some type of session timeout which would fire
the session end?
 
J

Josh

Somehow I want to capture browser close event and fire session abandon
which
will call session end. Please help.

I think you are missing a trick. The behaviour is a feature. I think users
can close thier browser and then reconnect to thier session if it was an
accident.

What do you have to clear out? Have you got a lot of data in the session?
 
P

Patrice

My personal preference is to not tied clean up to the normal application
flow. I tend to prefer to have a dedicated clean up routine that cleans
whatever needs to be cleaned.

You could use onbeforeclose but it's likely you'll find cases where it
doesn't fire (such as crashed browser etc...) plus session_end don't work
for other session providers etc...

Patrice
 
E

Eliyahu Goldin

Start from googling newsgroups to see how other people use it. I don't have
personal experience with it, that's why I put a careful "Consider" in my
post. Could be it doesn't help at all. Consider it. Make your own research.

Eliyahu
 
J

James Steele

More specifically.. once the parent window and ALL child windows (app
may have used window.open to open other windows under the same session)
have been closed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top