Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show online users

Status
Not open for further replies.

daveigh

Programmer
Oct 9, 2003
105
0
0
hi guys,

im now in process of including a site feature that can show if user is online. I'd like to incorporate this feature so if the user is online, i can simply chat with em.

on my online research, im redirected to using global.asa files (which im not quite familiar coz i dont normally use this with my previous sites). but after learning its use, im quite at loss. see, the global.asa file has its use on start & on end of the application. but what if as I opened the site, i do not login yet, meaning if i included the online detecting function, it wont be running if I put it in the global.asa file, right?

If you can redirect me to sites or forum threads, it will be highly appreciated!

thx in advance!!! =)

______________CRYOcoustic_____________
 
I have achieved a similar function by altering the Login table and adding one more field, "LoggedOn".

When they log in you set LoggedOn = 1.
On loggin out you set it back to 0

Select * from login where LoggedOn = 1

will give you who is online.


If you want to do something more refined, you may simply add a new table, similar to a login log where you can also store information about how long and how frequently they are online, so that you can show your "Best Users".

A structure similar to

create table LoginLog
(
LoginID int
Date date,
LoginTime Time,
LogoutTime Time
)

YOu will generate a new record every time the user is logged in and you update the same record when he/she is logged out.

The list of users online will be:

Select * from LoginLog where Logouttime IS NULL"


Cheers

Qatqat

Life is what happens when you are making other plans.
 
Qatqat

I had also done the same on my site but not as refined as yours. I just set a flag to when they are logged in. But I was wondering what if a user just closes the browser instead of actually clicking on a log out link. That would not change the flag then.

Regards
Satish
 
Good point

You can include an onUnload function in the page that will redirect to a logout.asp page.


QatQat

Life is what happens when you are making other plans.
 
Use the session_OnStart and Session_OnEnd events in the global.asa file - then there will only be a lag of the length of the session (usually 30 mins) and doesn't depend on whether the user explicitly logs out or not - or fires the onunload event (which is not guaranteed, and is at page level). It can also capture no. of guests this way - use the session id as the key, user name as guest or their real username if they're logged in.

Inside an Application Variable create either an array of usernames or an xml data structure - depending on your needs. Add to this in the OnStart event (for guests) and during log on (for registered users), and remove in the OnEnd event (which you can also do when the user explicitly logs out). If you use XML then you can write a simple XSLT to present it on your pages - but XML is usually many times larger in size than a simple array - so do your calculations to ensure this doesn't eat up your memory or slow your pages down.

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top