473,385 Members | 1,942 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,385 software developers and data experts.

Tracking users when browser is closing

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

--
------------------------------
Jon Haakon Ariansen
System Consultant
Jul 19 '05 #1
11 3417
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" <ha****@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
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

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

Jul 19 '05 #2
hawkon wrote:
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

--
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 19 '05 #3
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" wrote:
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" <ha****@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com...
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

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


Jul 19 '05 #4
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

Jul 19 '05 #5
Yan Roosens wrote:
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.

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
--
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 19 '05 #6
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...
Jul 19 '05 #7
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" <ro***@pacifictec.com> wrote in message
news:O$**************@TK2MSFTNGP12.phx.gbl...
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...
Jul 19 '05 #8
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #9
"Alex Kail" <ka***@hotmail.com> wrote in message
news:eU*************@TK2MSFTNGP12.phx.gbl...
| 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
|
| *** Sent via Developersdex http://www.developersdex.com ***
| 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).
Jul 19 '05 #10
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #11
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).
"Alex Kail" <ka***@hotmail.com> wrote in message
news:eR**************@tk2msftngp13.phx.gbl...
| 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
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #12

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

Similar topics

4
by: Adam | last post by:
Greetings, I am creating a web application, which I will be selling licenses to be able to use it. So Customer Group A, could purchase 3 licenses, Customer Group B could purchase 30. With...
8
by: gil | last post by:
I'm trying to track how many users are visiting a site and how may are logged in, using application sessions like so: Sub Session_OnStart Session.Timeout = 20 Session("Start") = Now...
2
by: Derek | last post by:
Hello: I want to capture the event when a browser is closing, to give to the user the posibility of close or no this browser. When the browser is closing, this show a confirm window with two...
4
by: tperri | last post by:
I've got a user table with a field called Online, and when a user logs in, I set a value in this column to indicate they are online. And in the same fashion, when they click the logout button, I...
6
by: Bill Manring | last post by:
I have an ASP.NET application which my company sells comercially. We license on a concurrent user model, but we currently rely on the "honor" system for the customers to give us their best guess...
1
by: kasterborus | last post by:
Hi, My client is using the UBB Threads forum and I was recently asked to look into adding the ability to track the activity of each of the users to see who is more active than others. Users are...
2
by: C# programmer | last post by:
Hi All, I'm working on a project which requires tracking of recent document downloads. There is a feature in which user can download the docs without logining into the website for some of the...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
10
junior29
by: junior29 | last post by:
Hi, I just wondered if anyone could help me at all. I'm doing a piece of coursework building a social network (which is getting there!), we are supposed to add an administration element to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.