Get Current logged in users

  • Thread starter Thread starter Brendon Bezuidenhout
  • Start date Start date
B

Brendon Bezuidenhout

Hey all,

Newbie question I'm afraid: Is there a way to see/tell how many users are
currently logged into a website at all?

Thanks
Brendon
 
It depends upon what you mean by logged in. If you mean casual users who are
just visiting your site, then you'll need some tool to analyze your log
files to see that information. If you're using something like the ASP.Net
Membership system, then the
System.Web.Security.Membership.GetNumberOfUsersOnline() function will show
the number logged int.
 
Hi,

Brendon said:
Newbie question I'm afraid: Is there a way to see/tell how many users are
currently logged into a website at all?

you could use the Session_Start and Session_End functions (Global.asax) to
track who logged on and off. However, since sessions may remain for
whatever duration has been specified (unless users explicitly log off), the
expressiveness of the so calculated figure will be doubtful at best.

Cheers,
Olaf
 
Heya Olaf,

Ermmmmmmm *blank look* - I'm a newbie to ASP.net moving form Win Forms to
Web Forms lol.... Thanks for the pointers re: Global.aspx... Where/How do I
set the sessions timeout as such?

Brendon
 
There's a nice writeup here, that talks about three seperate methods to
go about doing this:

http://classicasp.aspfaq.com/general/how-do-i-count-the-number-of-current-users/sessions.html

In response to your last question, I believe you can set the timeout
within your global.asax file. Within the sessionState tag, add an
attribute such as:
timeout="60"
The 60 means that the session would timeout after 60 minutes. I haven't
done much with session states, so there could be another method to go
about doing this.
 
Thanks a million for that Josh - Makes things a little clearer for me :)

Not as convoluted as the security framework I have to deal with at work
thankfully lol
 
Hi,

There's a nice writeup here, that talks about three seperate methods to
go about doing this:

http://classicasp.aspfaq.com/general/how-do-i-count-the-number-of-current-users/sessions.html

great link - thanks!
In response to your last question, I believe you can set the timeout
within your global.asax file. Within the sessionState tag, add an
attribute such as:
timeout="60"
The 60 means that the session would timeout after 60 minutes.

I.e.:
....
<system.web>
...
<sessionState mode="InProc" timeout="20"/>
...
I haven't done much with session states, so there could be another method
to go about doing this.

You could also set this within your website's IIS-settings (see the State
Managment strip). And I guess (!) you might do so in the machine.config
file, but I never tried that.

Cheers,
Olaf
 
Hi,


also, there's another more or less built-in method of counting users. If
you use the membership-provider, check out the GetNumberOfUsersOnline-prop,
i.e.:
lblUserInfo.Text = Membership.GetNumberOfUsersOnline().ToString;

Cheers,
Olaf
 
Back
Top