Tracking users when browser is closing

H

hawkon

Hi all,

I have an important question to ask about how to trap events when the user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table where I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow without using the logout button. I have tried putting in code in Session_onend, but it doesn't seem to run if the browser is closed. Eg. tracking visitors in a application variable in Session_OnStart and Session_OnEnd.
So if there is any solutions on a safe way on logging users in a database, please let me know!
In advance thank you very much!!

Kind regards,

Jon Haakon
 
B

Bob Barrows [MVP]

hawkon said:
Hi all,

I have an important question to ask about how to trap events when the
user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table
where I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow
without using the logout button. I have tried putting in code in
Session_onend, but it doesn't seem to run if the browser is closed.
Eg. tracking visitors in a application variable in Session_OnStart
and Session_OnEnd. So if there is any solutions on a safe way on
logging users in a database, please let me know!
In advance thank you very much!!

Kind regards,

Jon Haakon

It is unlikely that you will get much help with client-side code and events
in an asp group (asp is server-side technology). While many here do have
knowledge about client-side code, they are unlikely to answer such questions
here because their desire is to come to this group to discuss asp. You will
have better success getting a helpful response on one of the dhtml or
scripting newsgroups.

That said, the closing of the browser window does not raise any trappable
events. The window_onclose event does not fire when the browser is closed.

Sorry.


Aaron has an article on his site about tracking database use that you may
find helpful: http://www.aspfaq.com/show.asp?id=2491

Bob Barrows
 
H

hawkon

Sounds very nice - however I've been looking for html close event without any luck.
So my question would be - what kind of close event can I use that is supported by the main browsers like MSIE, Netscape and Opera??

In advance thank you very much!

Kind regards,

Jon Haakon
--
------------------------------
Jon Haakon Ariansen
System Consultant


UncleWobbly said:
use an html onclose event to launch another page that will briefly pop-up,
make the necessary tweaks to your data and them close itself... of course
this is defeated if they have a pop-up killr but you are no further back.

hawkon said:
Hi all,

I have an important question to ask about how to trap events when the user
close the browser window.
I'm a ASP programmer and I have s MSSQL database with a user table where
I'm able to track if the user is logged in or not.
However this is not easy to track if the user close the browserwindow
without using the logout button. I have tried putting in code in
Session_onend, but it doesn't seem to run if the browser is closed. Eg.
tracking visitors in a application variable in Session_OnStart and
Session_OnEnd.
 
Y

Yan Roosens

Hi,

Sounds very nice - however I've been looking for html close event without any luck.

No really an html event, but rather a Javascript event.

<body onClose="do_your_thing()">

Yan
 
B

Bob Barrows [MVP]

Yan said:
Hi,



No really an html event, but rather a Javascript event.


Just to be picky, it's not a Javascript event. It's a DOM event. Document
Object Model. Totally separate from Javascript, although it is usable by
Javascript as well as vbscript.
<body onClose="do_your_thing()">
I've found this to be unreliable when attempting to catch browser closes.

Bob Barrows
 
R

rob_d

Jon,

I am having that exact same issue. I am desperately trying to figure it out, as this problem is causing a delay in the development of the project I am working on. If you (or anyone else for that matter) find a solution, please don't hesitate to email it to me. Likewise, should I solve this dilemma, I will post it immediately as well as email it to everyone in this thread that has a readable email address.

Thanks in advance,
--------------------------
Rob Davidson
Software Engineer
PacificTec, Inc.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
P

Phillip Windell

There is no solution. You simply can not do it. That is why a stateless "web
application" is not the proper solution for every situation.

--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com

Robert Davidson said:
Jon,

I am having that exact same issue. I am desperately trying to figure it
out, as this problem is causing a delay in the development of the project I
am working on. If you (or anyone else for that matter) find a solution,
please don't hesitate to email it to me. Likewise, should I solve this
dilemma, I will post it immediately as well as email it to everyone in this
thread that has a readable email address.
Thanks in advance,
--------------------------
Rob Davidson
Software Engineer
PacificTec, Inc.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 
A

Alex Kail

I just finished up a feature like this on my community website. My
solution was to use an IFrame with an ASP page that I called
WhosOnline.asp. This is a self refreshing page that refreshes every 30
seconds.

The page executes a stored procedure on SQL Server that modifies and
reads a table called WHOS_ONLINE_T. This table only has two fields
(member_id and date_visited). Basically what the procedure does is
deletes any records in which the date visited is older than 35 seconds,
plugs in the members id and date visited (or updates the record if the
member is already present in the table with the current date/time). Then
the proc returns all records from the table.

It works beautifully and as a result the data in the table is only 30
seconds stale at most. Not bad for given that we are in a stateless
environment.

If you are interested, email me and I can give you the specs. It tooke
me less than an hour to completely code.

Alex Kail
 
L

Lord Merlin

| I just finished up a feature like this on my community website. My
| solution was to use an IFrame with an ASP page that I called
| WhosOnline.asp. This is a self refreshing page that refreshes every 30
| seconds.
|
| The page executes a stored procedure on SQL Server that modifies and
| reads a table called WHOS_ONLINE_T. This table only has two fields
| (member_id and date_visited). Basically what the procedure does is
| deletes any records in which the date visited is older than 35 seconds,
| plugs in the members id and date visited (or updates the record if the
| member is already present in the table with the current date/time). Then
| the proc returns all records from the table.
|
| It works beautifully and as a result the data in the table is only 30
| seconds stale at most. Not bad for given that we are in a stateless
| environment.
|
| If you are interested, email me and I can give you the specs. It tooke
| me less than an hour to completely code.
|
| Alex Kail
|
|
| Don't just participate in USENET...get rewarded for it!

This sounds like a very good piece of code, but how compatible is it? Does
it work with browsers like firefox / mozilla / opera / crazy browser /
netscape / WebTV. I don't want to start a flame war, but isn't the whole
point behind development to be able to reach as many clients as possible? I
know quite a while ago iFrame was limited to IE only, so my question is,
would it be an acurate measurement tool if you have users using these other
browsers? Most of my sites are does not limit what browser can be used, and
it would be nice to know your code is compatible :)



--


Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 
A

Alex Kail

I know this works in IE 6 and Netscape 7.02. No problems that I have
seen. I have all flavors accessing the site, including a WebTV user,
1100 all together and I haven't heard anyone scream.

Alex
 
L

Lord Merlin

Wow, that's quite remarkable. Would you mind sharing the code? :)

--


Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
| I know this works in IE 6 and Netscape 7.02. No problems that I have
| seen. I have all flavors accessing the site, including a WebTV user,
| 1100 all together and I haven't heard anyone scream.
|
| Alex
|
|
| Don't just participate in USENET...get rewarded for it!
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top