ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 300,362 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,485 people online right now. Registration is fast and FREE... Join Now!




How to track no of users currently logged in to the web site

 

How to track no of users currently logged in to the web site

robins

29 Jun, 2009 - 09:26 PM
Post #1

New D.I.C Head
*

Joined: 18 Oct, 2008
Posts: 1

Hi...

This is my first post....

I`m beginner & working with Visual Studio 2008 & C#.

I`m developing a web site. I want to track no of users currently logged in to the site.I`ve managed it by usisng session.
It is working fine if a user loged out by clicking the 'Sign Out' button.

But if the user closes the browser or uses Task manager to close the bowser, then the count is not correct.

How can I handle it accurately..?

Any help would be greatly appreciated.

Regards
Robins[font=Times New Roman]

User is offlineProfile CardPM
+Quote Post


Karthik_rao

RE: How To Track No Of Users Currently Logged In To The Web Site

30 Jun, 2009 - 03:49 AM
Post #2

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 5


Hi,

in the Global.asax file, you have method called session_start and session_end.

at the time of session_start you can increase the hit count and in the session_end decrease the hit count.

like below:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("Sessions") = 0
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("Sessions") = CType(Application("Sessions"), Integer) + 1
Application.UnLock()
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("Sessions") = CType(Application("Sessions"), Integer) - 1
Application.UnLock()
End Sub



QUOTE(robins @ 29 Jun, 2009 - 09:26 PM) *

Hi...

This is my first post....

I`m beginner & working with Visual Studio 2008 & C#.

I`m developing a web site. I want to track no of users currently logged in to the site.I`ve managed it by usisng session.
It is working fine if a user loged out by clicking the 'Sign Out' button.

But if the user closes the browser or uses Task manager to close the bowser, then the count is not correct.

How can I handle it accurately..?

Any help would be greatly appreciated.

Regards
Robins[font=Times New Roman]


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 08:14PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month