473,399 Members | 3,106 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,399 software developers and data experts.

Tracking user logins with Session_End or other

I would like to keep track of users when they are 'on'. On Session_Start I
can write a DB record about them, but there does not seem to be session
variable information during the Session_end event which I could use to
update the record that they are logged out. This would also be nice to limit
multiple logins.

Is there a preferred way to track users login / logout /session time and
multiple logins ?

TIA
Jun 27 '08 #1
5 2745
"Ron J" <rj******@atsecure.netwrote in message
news:eN**************@TK2MSFTNGP03.phx.gbl...
I would like to keep track of users when they are 'on'. On Session_Start I
can write a DB record about them, but there does not seem to be session
variable information during the Session_end event which I could use to
update the record that they are logged out. This would also be nice to
limit multiple logins.

Is there a preferred way to track users login / logout /session time and
multiple logins ?

Session_End fires only when using inproc sessions.

If you're using inproc sessions, you can use Session_End to update a
database etc. When a session begins, store the userid of the user logging in
as a session variable, and it will be available to use in Session_End.

HOWEVER...

Session_End fires when the session ends. This means that you will need to
tear the session down through code i.e. by means of a "Logout" button -
otherwise, Session_End will fire when the session times out naturally, by
default after 20 minutes of inactivity. Session_End does *not* fire if the
user simply closes their browser etc...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
Nice. Thanks.
What if I want to store session 'out of process' on the SQL server or State
Server?

Thanks

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e$**************@TK2MSFTNGP05.phx.gbl...
"Ron J" <rj******@atsecure.netwrote in message
news:eN**************@TK2MSFTNGP03.phx.gbl...
>I would like to keep track of users when they are 'on'. On Session_Start
I can write a DB record about them, but there does not seem to be session
variable information during the Session_end event which I could use to
update the record that they are logged out. This would also be nice to
limit multiple logins.

Is there a preferred way to track users login / logout /session time and
multiple logins ?


Session_End fires only when using inproc sessions.

If you're using inproc sessions, you can use Session_End to update a
database etc. When a session begins, store the userid of the user logging
in as a session variable, and it will be available to use in Session_End.

HOWEVER...

Session_End fires when the session ends. This means that you will need to
tear the session down through code i.e. by means of a "Logout" button -
otherwise, Session_End will fire when the session times out naturally, by
default after 20 minutes of inactivity. Session_End does *not* fire if the
user simply closes their browser etc...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #3
"Ron J" <rj******@atsecure.netwrote in message
news:up*************@TK2MSFTNGP05.phx.gbl...

[top-posting corrected]
>Session_End fires only when using inproc sessions.
What if I want to store session 'out of process' on the SQL server or
State Server?
Session_End won't fire...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #4
Mark,
Fair enough. I'm trying to access inproc Session vars in Session_end but the
the current.Session is already null. I'm seeing some articles that say
AcquireRequestState must fire first, but not sure how to do this. Basically,
I have no access to session variable in the Session_end event. How can I
access them ?

thanks

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
"Ron J" <rj******@atsecure.netwrote in message
news:up*************@TK2MSFTNGP05.phx.gbl...

[top-posting corrected]
>>Session_End fires only when using inproc sessions.
>What if I want to store session 'out of process' on the SQL server or
State Server?

Session_End won't fire...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #5
Ok, solved it. I was using something like
System.Web.HttpContext.Current.Session("name") (since there is no web
request)
This is not available in Session_End, but just
Session["name"] is.

Thanks

"Ron J" <rj******@atsecure.netwrote in message
news:ut**************@TK2MSFTNGP04.phx.gbl...
Mark,
Fair enough. I'm trying to access inproc Session vars in Session_end but
the the current.Session is already null. I'm seeing some articles that say
AcquireRequestState must fire first, but not sure how to do this.
Basically, I have no access to session variable in the Session_end event.
How can I access them ?

thanks

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:e2**************@TK2MSFTNGP04.phx.gbl...
>"Ron J" <rj******@atsecure.netwrote in message
news:up*************@TK2MSFTNGP05.phx.gbl...

[top-posting corrected]
>>>Session_End fires only when using inproc sessions.
>>What if I want to store session 'out of process' on the SQL server or
State Server?

Session_End won't fire...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


Jun 27 '08 #6

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

Similar topics

1
by: Sameer | last post by:
one important problem i am facing is that my web solution (asp.net) will be deployed on a webfarm. I am using sql server session management on clustered sqlservers. but as i need to prevent...
6
by: KS | last post by:
I have made a WebForm with log ON/OFF off users. There is a label that shows the total count off users logged on stored in Application("UserCount") It works fine if the users logs out WITH THE...
3
by: Dan Walls | last post by:
Hi, I am looking to clean up some database locks whenever a user session ends. A user session ends whenever they: a. shut down the browser and the session times out after 20 mins (20 mins is...
17
by: Alphonse Giambrone | last post by:
I am building a web app for users to add/edit data. They may add/edit several records during a session. When they are done (not necessarily immediately, could be 10 or more minutes later), I need...
6
by: anoj | last post by:
Hi All i need to prevent multiple logins from the same user at the same time. what is the best way to do this . How can i detect if a user closes the browser window without logging out so tht...
5
by: news.microsoft.com | last post by:
Hi everyone, I need some help (may be in the form of some sample code) for the subject question. I have an ASP.NET/C# application. I need to do quite a few tasks when the session ends. I...
4
by: Paul | last post by:
I have an ASP.NET application that I want to limit # of concurrent logins. Has anyone done similar things before? I was trying to increment a counter in the application and decrement the counter in...
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...
2
by: jlaustill | last post by:
Hello everyone, I have a fairly unique need :) I am trying to determine the use/clients for databases in my corporation that I am maintaining, but that noone seems to know what they are for. Many...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.