Triggering Session_OnEnd when user close window

P

Petter Harnes

We have a solution where we want to control the number of users logged
in at the same time.

So when the user log in we check number of currentusers agains
allowedusers and increment a currentusers (in the database).

On Session_onEnd or when a user logout (actually I abandon the session
on logout) we decrease currentusers.

But as we all know when the browser is closed or the user just go to
another site this decrease does not appear.

It will of course trigger when Session goes to timeout, but I imagine
a lot of angry users calling support when they are denied access.



Petter Harnes
Technical Manager
Eiendomsverdi AS
http://www.ev.no
 
G

Ganesh

Hi,

There is no straight forward method to do this. But I think you can try the
following.

Use inline vbscript function to track whether a session exists on window
close (body onunload). If it exists then kill it.

Constraints:
1. This works only in Internet Explorer browser.
2. Body onunload event does not get trigerred every time correctly.

Ganesh
 
B

Bob Barrows [MVP]

Petter said:
We have a solution where we want to control the number of users logged
in at the same time.

So when the user log in we check number of currentusers agains
allowedusers and increment a currentusers (in the database).

On Session_onEnd or when a user logout (actually I abandon the session
on logout) we decrease currentusers.

But as we all know when the browser is closed or the user just go to
another site this decrease does not appear.

It will of course trigger when Session goes to timeout, but I imagine
a lot of angry users calling support when they are denied access.
http://www.aspfaq.com/show.asp?id=2491

Bob Barrows
 
J

John Blessing

Petter Harnes said:
We have a solution where we want to control the number of users logged
in at the same time.

So when the user log in we check number of currentusers agains
allowedusers and increment a currentusers (in the database).

On Session_onEnd or when a user logout (actually I abandon the session
on logout) we decrease currentusers.

But as we all know when the browser is closed or the user just go to
another site this decrease does not appear.

It will of course trigger when Session goes to timeout, but I imagine
a lot of angry users calling support when they are denied access.



Petter Harnes
Technical Manager
Eiendomsverdi AS
http://www.ev.no

There is no simple solution. I found it best to implement my own timeout.
When a user logs in, create a record in the database. Each time the user
acesses the database, update a "lastused" value for that user.

If session_onend fires (and it is not reliable), remove that user from the
"currentusers" table.

When someone logs in, remove any currentusers whose "lastused" value is
older than the interval you think is reasonable.


--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top