473,405 Members | 2,141 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,405 software developers and data experts.

How to Track User Login

Mel
I am using "windows" authentication mode. I would like to store the
username and various information when the user logs on to the website.
Any ideas?

It would be a bonus to store the logout time too but I hear that is
difficult and unreliable but if anyone knows a way to do that too I am
all ears.
(Visual Studio 2005, Asp.net 2.0, Visual Basic)

Aug 15 '07 #1
10 3119
Hi Mel,
if you are using windows authentication IIS is responible for authenticating
your user. Do you allow anonymous users to access your application? If no you
can handle your login in Session_Start. Handling logout is difficult because
if user closes browser you do not receive any information about it (unless
you build some mechanism to ping application from browser in short
intervals). You also can fully believe to Session_End because it is raised
only if session is running InProc = locally in asp.net worker process.

Regards,
Ladislav

"Mel" wrote:
I am using "windows" authentication mode. I would like to store the
username and various information when the user logs on to the website.
Any ideas?

It would be a bonus to store the logout time too but I hear that is
difficult and unreliable but if anyone knows a way to do that too I am
all ears.
(Visual Studio 2005, Asp.net 2.0, Visual Basic)

Aug 15 '07 #2
*You also cannot believe to Session_End ...

"Ladislav Mrnka" wrote:
Hi Mel,
if you are using windows authentication IIS is responible for authenticating
your user. Do you allow anonymous users to access your application? If no you
can handle your login in Session_Start. Handling logout is difficult because
if user closes browser you do not receive any information about it (unless
you build some mechanism to ping application from browser in short
intervals). You also can fully believe to Session_End because it is raised
only if session is running InProc = locally in asp.net worker process.

Regards,
Ladislav

"Mel" wrote:
I am using "windows" authentication mode. I would like to store the
username and various information when the user logs on to the website.
Any ideas?

It would be a bonus to store the logout time too but I hear that is
difficult and unreliable but if anyone knows a way to do that too I am
all ears.
(Visual Studio 2005, Asp.net 2.0, Visual Basic)
Aug 15 '07 #3
Mel
On Aug 15, 10:14 am, Ladislav Mrnka
<LadislavMr...@discussions.microsoft.comwrote:
Hi Mel,
if you are using windows authentication IIS is responible for authenticating
your user. Do you allow anonymous users to access your application? If no you
can handle your login in Session_Start. Handling logout is difficult because
if user closes browser you do not receive any information about it (unless
you build some mechanism to ping application from browser in short
intervals). You also can fully believe to Session_End because it is raised
only if session is running InProc = locally in asp.net worker process.

Regards,
Ladislav

"Mel" wrote:
I am using "windows" authentication mode. I would like to store the
username and various information when the user logs on to the website.
Any ideas?
It would be a bonus to store the logout time too but I hear that is
difficult and unreliable but if anyone knows a way to do that too I am
all ears.
(Visual Studio 2005, Asp.net 2.0, Visual Basic)
Cool. I will just add a Global.asax to my project and try adding my
code to the Session_Start procedure. I'll post the code here when I
get it finished.

Aug 15 '07 #4
You can put that into the Session_Start event in the Global.asax. In
fact, I don't see why you can't put the logout code in the Session_End
event. The logout time may not be accurate to the minute, because of the
session timeout, but you can get it pretty close...

Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
Mel wrote:
I am using "windows" authentication mode. I would like to store the
username and various information when the user logs on to the website.
Any ideas?

It would be a bonus to store the logout time too but I hear that is
difficult and unreliable but if anyone knows a way to do that too I am
all ears.
(Visual Studio 2005, Asp.net 2.0, Visual Basic)
Aug 20 '07 #5
Steve C... If the Session_End never ever ever ever fires what is the
reason? - I've not ever been able to get it to fire and my Sessionstate
mode is "Inproc"

So far I see no validity in saying you can rely on Session_End since no
one on the web has been able to answer this question consistently.

*** Sent via Developersdex http://www.developersdex.com ***
Sep 4 '07 #6
Never say never.
How do you know that it's never ever fires?
It does always fire but if you have a bug in the code for Session_End then
it will quietly throw an exception and be caught by ASP.NET without you
knowing. Like for example if you tried to use Response or Request objects in
Session_End code.

Might have a trace in NT Event log though...

George.

"Dan Colgan" <da*******@dcolgan.comwrote in message
news:Ow**************@TK2MSFTNGP03.phx.gbl...
Steve C... If the Session_End never ever ever ever fires what is the
reason? - I've not ever been able to get it to fire and my Sessionstate
mode is "Inproc"

So far I see no validity in saying you can rely on Session_End since no
one on the web has been able to answer this question consistently.

*** Sent via Developersdex http://www.developersdex.com ***

Sep 4 '07 #7
you can rely on session_end if you use inproc, and there are no recyle
events. check your event log for recycles.
-- bruce (sqlwork.com)

Dan Colgan wrote:
Steve C... If the Session_End never ever ever ever fires what is the
reason? - I've not ever been able to get it to fire and my Sessionstate
mode is "Inproc"

So far I see no validity in saying you can rely on Session_End since no
one on the web has been able to answer this question consistently.

*** Sent via Developersdex http://www.developersdex.com ***
Sep 4 '07 #8
Here's the code - you tell me why it doesn't fire

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Const strLogFilePath= "C:\Inetpub\wwwroot\AOPCTraining\session.log"

Sub Application_OnStart
Application("Start") = Now()
End Sub

Sub Session_OnStart
Session.Timeout = 1
Session("Start") = Now()

Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLogFilePath, 8, True)
Set objFSO = Nothing
objFile.WriteLine "Session: " & Session.SessionID & " started at " &
Now ()
objFile.Close
Set objFile = Nothing
End Sub

Sub Session_OnEnd
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLogFilePath, 8, True)
Set objFSO = Nothing
objFile.WriteLine "Session: " & Session.SessionID & " ended at " & Now
()
objFile.Close
Set objFile = Nothing
End Sub

Sub Application_OnEnd
End Sub

</SCRIPT>

*** Sent via Developersdex http://www.developersdex.com ***
Sep 4 '07 #9
I see, I thought you talking about ASP.NET not old asp.
It's known issue with plain ASP.
Also writing into file concurrently is not a good idea,
George.

"Dan Colgan" <da*******@dcolgan.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Here's the code - you tell me why it doesn't fire

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Const strLogFilePath= "C:\Inetpub\wwwroot\AOPCTraining\session.log"

Sub Application_OnStart
Application("Start") = Now()
End Sub

Sub Session_OnStart
Session.Timeout = 1
Session("Start") = Now()

Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLogFilePath, 8, True)
Set objFSO = Nothing
objFile.WriteLine "Session: " & Session.SessionID & " started at " &
Now ()
objFile.Close
Set objFile = Nothing
End Sub

Sub Session_OnEnd
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strLogFilePath, 8, True)
Set objFSO = Nothing
objFile.WriteLine "Session: " & Session.SessionID & " ended at " & Now
()
objFile.Close
Set objFile = Nothing
End Sub

Sub Application_OnEnd
End Sub

</SCRIPT>

*** Sent via Developersdex http://www.developersdex.com ***

Sep 4 '07 #10
This same exact code is in my global.asax file as well and it doesn't
work there either. ASP or ASP.net doesn't seem to matter, it just
doesn't work.

It seems puzzling to me why the code which is almost word for word in
the session_start doesn't work in the session_end? -

*** Sent via Developersdex http://www.developersdex.com ***
Sep 4 '07 #11

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

Similar topics

2
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...
5
by: | last post by:
(subject included - apologies) <jason@catamaranco.com> wrote in message news:... > Is there a simple way to track users leaving our site to vendors whose wares > we have advertised as a banner...
3
by: LC | last post by:
hi, i worry about people doing something they shouldn't to my db and I would like to track any structural changes (who and which)to my db. I am using oracle 8.0.6.0.0 and 9.2.0.2.0. regards,...
4
by: Nicole | last post by:
Hello: I have a shared database running on a network drive. I would like to track when record changes occur and who did it. Problem 1: I'm not able to tack changes, when they occur in...
5
by: tshad | last post by:
If I am using FormsAuthentication, is there a way to check who is logged in? I want to be able to check at any particular time, not just how many people are logged in, but who they are. One...
7
by: andrea | last post by:
Which is the best way to track the number of the user currently logged into a web site? I've some idea on mind, but I want to compare with you. One could be to increment a session variable on...
10
by: Mitul | last post by:
Hello everybody, I am developing a community site and almost all works are competed. There is major issue that I am facing is how to track user's online status. I am using session data to save...
1
by: jeffblk | last post by:
Hello: Is there a simple way to track who is entering records into a database? We have a one table, one form simple database that two people use to assign medical cases. We would like to know which...
11
by: glenh | last post by:
I have a web app that is running a photo competition. Basically any user should be able to vote on a photo with a rating between 1 and 5. At the end of the competition the photo with the highest...
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: 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
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.