Get Current logged in users

  • Thread starter Brendon Bezuidenhout
  • 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
 
M

Mark Fitzpatrick

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.
 
O

Olaf Rabbachin

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
 
B

Brendon Bezuidenhout

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
 
J

joshie

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.
 
B

Brendon Bezuidenhout

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
 
O

Olaf Rabbachin

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
 
O

Olaf Rabbachin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top