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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is member online?

Status
Not open for further replies.

akgta

Programmer
Jul 18, 2007
42
CA
how can we find out that a particular member is logged into our website right now?

is it possible using sessions, since sessions data is kept on the server in a file. or is there a better or simpler way to find out?

thanks in advance
 
Hi

I would say, all depends on how you organized your member database.

Personally I would think to "manually" analyze the session files only as the last option.

Feherke.
 
how do you define 'logged into', given the web is a stateless environment (largely)?

most analysis treats active users as those that have visited a page or a site resource in the last X minutes.

once you have determined that this is a satisfactory method for you, you can then easily query your database of visits (which one assumes you keep for stats purposes).

alternatives (and not recommended) you could put some javascript on all your pages that creates a 5 second heartbeet with some cookie or other identifier, and you can use that to determine 'online' status.

either way, you need some sensible log of time of visit and identifier.
 
Interesting one from jpaddie, I think the cookie solution would only allow the page to check itself it is was posted back to the server. Reading between the lines it loks like you need a script that will run and tell you who is logged in now, you might run this at any time.
If your users need to authenticate to the site then you should be ok to have some kind of timestamp on the user record in the database which you can query. Each time any page is requested you would have to update the time stamp with the current time (you might even do this to implement a time out e.g. it's more than 20 mins since your last visit).
The session file stuff is interesting. Maybee just wordology here but sessions are held on 1 file per session basis not in one big file so you might be able to just look at the time stamps from an ls or dir to see who hasn't been here for 20 mins.
Now what I just said might not be true, you might have some custom session handler which does store all session info in a single file. You could even create your own session handler to hold session info in a database (good for web server farms) .
Also bear in mind that sessions are just that, you don't have to have any authentication to use them do your site could be all anonympus users, if you need to know the actual person who is logged in you will need to add that user name to the session details in ay case.
Hope this makes some sense !
 
by 'heartbeet' ([sic] I meant heart beat) i intended to imply that the javascript would asynchronously (AJAX) report back to the server to say that the user was still on-page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top