473,503 Members | 11,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tracking logged in users and visitors

gil
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
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
The problem is that I don't know whose session is ending, a logged in user
or a visitor and therefore can't decrement when one or the others session
ends.

Is it possible to identify the session that is ending by name so I can track
two different sets of data, one for visitors and one for users? What is a
good way to go about this consdering that users won't always click the
"logout" button when ending their visit?


Thank you



Jul 22 '05 #1
8 1675
How about:

Sub Session_OnStart()
Application.Lock
Application("TotalUsers") = Application("TotalUsers") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
If Session("Username") = "" Then
Application("Visitors") = Application("Visitors") - 1
Else
Application("RegisteredUsers") = Application("RegisteredUsers") - 1
End If
Application.Unlock
End Sub
And in your login code,

<%
'''code for login
Application.Lock
Application("RegisteredUsers") = Application("RegisteredUsers") + 1
%>

Ray at work
"gil" <gi*@nospam.thankyou> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
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
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") + 1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application("ActiveUsers") = Application("ActiveUsers") - 1
Application.UnLock
End Sub
The problem is that I don't know whose session is ending, a logged in user
or a visitor and therefore can't decrement when one or the others session
ends.

Is it possible to identify the session that is ending by name so I can
track
two different sets of data, one for visitors and one for users? What is a
good way to go about this consdering that users won't always click the
"logout" button when ending their visit?


Thank you



Jul 22 '05 #2

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
How about:

Sub Session_OnStart()
Application.Lock
Application("TotalUsers") = Application("TotalUsers") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
If Session("Username") = "" Then
Application("Visitors") = Application("Visitors") - 1
Else
Application("RegisteredUsers") = Application("RegisteredUsers") - 1
End If
Application.Unlock
End Sub
And in your login code,

<%
'''code for login
Application.Lock
Application("RegisteredUsers") = Application("RegisteredUsers") + 1
%>

Ray at work

Ray,

on a similar theme I'd like to check for the existance of someone being
logged on. I posted a day or so ago and had a reply from Tom, and I've
looked at the FAQ but the global.asa and application stuff is new to me and
so this might be a little beyond my scope.

I'm trying to see if someone is logged on by checking to see if a session
exisits in their name, how would I go about this?

many thanks
Jul 22 '05 #3
Write the info to a database when they logon.

"Alistair" <ma**@alistairbremoveme.co.uk> wrote in message
news:10************@corp.supernews.com...

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:%2****************@TK2MSFTNGP14.phx.gbl...
How about:

Sub Session_OnStart()
Application.Lock
Application("TotalUsers") = Application("TotalUsers") + 1
Application.Unlock
End Sub

Sub Session_OnEnd()
Application.Lock
If Session("Username") = "" Then
Application("Visitors") = Application("Visitors") - 1
Else
Application("RegisteredUsers") = Application("RegisteredUsers") - 1 End If
Application.Unlock
End Sub
And in your login code,

<%
'''code for login
Application.Lock
Application("RegisteredUsers") = Application("RegisteredUsers") + 1
%>

Ray at work
Ray,

on a similar theme I'd like to check for the existance of someone being
logged on. I posted a day or so ago and had a reply from Tom, and I've
looked at the FAQ but the global.asa and application stuff is new to me

and so this might be a little beyond my scope.

I'm trying to see if someone is logged on by checking to see if a session
exisits in their name, how would I go about this?

many thanks

Jul 22 '05 #4

<je**@removeemergencyreporting.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
Write the info to a database when they logon.


yes I thought of this but most users don't logout, they just close the
browser and so the DB record would not get removed.
Jul 22 '05 #5
No, you remove the record when they log in again..typical setup

Jeff
"Alistair" <ma**@alistairbremoveme.co.uk> wrote in message
news:10*************@corp.supernews.com...

<je**@removeemergencyreporting.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
Write the info to a database when they logon.


yes I thought of this but most users don't logout, they just close the
browser and so the DB record would not get removed.

Jul 22 '05 #6

<je**@removeemergencyreporting.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
No, you remove the record when they log in again..typical setup

Jeff
"Alistair" <ma**@alistairbremoveme.co.uk> wrote in message
news:10*************@corp.supernews.com...

<je**@removeemergencyreporting.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
> Write the info to a database when they logon.
>


yes I thought of this but most users don't logout, they just close the
browser and so the DB record would not get removed.



and how is that going to show when they are logged in??

when they log in the first time, I write a record in the DB that shows they
are logged in, then they close the browser, and if they don't log in for
another week then the record showing them as logged in is wrong for a week!!

Jul 22 '05 #7
Alistair wrote:
and how is that going to show when they are logged in??

when they log in the first time, I write a record in the DB that
shows they are logged in, then they close the browser, and if they
don't log in for another week then the record showing them as logged
in is wrong for a week!!


That's the nature of the beast. Aaron describes a strategy for deleting
inactive users in an article at www.aspfaq.com, but even that is not
perfect. You have to realize that with a stateless protocol like http, there
is no way to know for certain how many users are logged in.

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 #8
Exactly. With HTTP, there is NO guaranteed way to determine log out.

You can always implement logic that concludes that if a user has a login
record, but hasn't hit the database for an hour (or whatever), then they are
gone. Obviously this would imply that you would have to log every page hit
in the database.

Jeff

"Alistair" <ma**@alistairbremoveme.co.uk> wrote in message
news:10*************@corp.supernews.com...

<je**@removeemergencyreporting.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
No, you remove the record when they log in again..typical setup

Jeff
"Alistair" <ma**@alistairbremoveme.co.uk> wrote in message
news:10*************@corp.supernews.com...

<je**@removeemergencyreporting.com> wrote in message
news:u3**************@TK2MSFTNGP11.phx.gbl...
> Write the info to a database when they logon.
>

yes I thought of this but most users don't logout, they just close the
browser and so the DB record would not get removed.


and how is that going to show when they are logged in??

when they log in the first time, I write a record in the DB that shows

they are logged in, then they close the browser, and if they don't log in for
another week then the record showing them as logged in is wrong for a week!!

Jul 22 '05 #9

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

Similar topics

2
2603
by: marslee | last post by:
I want to prevent non-registered users to view a page in my website, For example, when a non-registered user clicks the history page, the website site refuses to go there since he is not...
11
3423
by: hawkon | last post by:
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...
1
2556
by: Robert Oschler | last post by:
This is my current strategy for tracking hyperlink clicking by a site visitor (Internet Explorer example): Using Javascript I: Attach an event to the document "onclick" handler. When a click...
5
1469
by: steves | last post by:
Hello, We are developing a web application written in classic ASP, which will end up running on Windows 2000 server. The site has a public side (the login page and related images), and a...
2
5143
by: MUHAMAMD SALIM SHAHZAD | last post by:
dear respected gurus, I would like to share ideas...as i learned from you and wish to tell that i had developed the system where i can audit each and every users and their actions(like...
2
1342
by: Nel | last post by:
I have a web site that seems to be getting hammered by lots of bots. Some genuine, some questionable. Some just users that seem to be downloading the site en-masse. I have started using php &...
2
11166
by: runner7 | last post by:
Can anyone tell me if there is a way in PHP to determine when a session times out on the server or how many concurrent sessions there are in your application?
2
1712
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...
2
1312
by: sparks | last post by:
At first they just wanted to keep a record of who logged in and when. Then it was if they made changes. Now its who changed what. BUT since this made no since to them. WHO put it in and who...
0
7212
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
7364
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...
1
5026
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...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.