473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Triggering Session_OnEnd when user close window

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
Jul 22 '05 #1
3 2228
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

"Petter Harnes" wrote:
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

Jul 22 '05 #2
Petter Harnes wrote:
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
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #3

"Petter Harnes" <pe**********@hotmail.com> wrote in message
news:68**************************@posting.google.c om...
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
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tom Bates | last post by:
I can successfully delete files using fso.DeleteFile when in an ASP script. But in Session_OnEnd, where I'd *really* like to clean up files, it appears that DeleteFile doesn't work. I've tried...
1
by: Soha El-Saeed | last post by:
Dear All; I wrote this code in the global.asa but it dosen't work inspite that it works in any asp file and also in the global.asa file but only in the session_onstart part.This code is to delete...
3
by: cab | last post by:
i have the following code in the "Sub Session_OnEnd" routine that does not seem to run..... Sub Session_OnEnd strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User...
24
by: Nancy Drew | last post by:
hi all i'm trying to keep users from being able to login to a site twice at the same time. everytime a user does a login, i stick their userID into an application scoped array. if they try to...
4
by: HolaGoogle | last post by:
hi there, i've 2 questions for you guys.... 1: is there any way to "force" a session_onend(), session timeout or at least call my logout method when a user leaves the application window without...
4
by: Renjith | last post by:
Hi When is Session_OnEnd event working , ive tried Abandon , Timeout still its not working. will a session end , while closing the browser window ?? Renjith.
4
by: anand | last post by:
In my website i want to trace the event when user log off from the site by closing the explorer so i am unable to run any server side program at that time and my session_onend event also not...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.