Jump to content


Photo

listing online users


  • Please log in to reply
4 replies to this topic

#1 uraniumdeer

uraniumdeer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 June 2006 - 11:11 AM

I'm still quite new to PHP but threw myself into a bigger project, I'm trying to caode a forum.
I do realize that it's a big task, but I'm not that far from finishing it.

My problem is that I'd like to list the users that are online, much like this forum does, list logged in people, and visitors - but i have absolutely no idea how to do this.

Any help would be appreciated - a push in the right direction will suffice, though a solution with comments to explain how it work would be really nice :)

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 27 June 2006 - 11:44 AM

As a start, might take a look here...

[a href=\"http://www.llstudios.net/directory/16-1\" target=\"_blank\"]http://www.llstudios.net/directory/16-1[/a]

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 27 June 2006 - 11:51 AM

hi,

This is a not something that can be achive easily and quickly. You need to consider your designing and structure of your code.
There are many ways to achieve this, but this is within my experience:

1. a session table. This table have fields like this:
sessionid, ip, username, status, timestamp.

sessionid hold the session id of user
ip: hold the ip
username hold the username, if not found, put a value of 'guest'
timestamp: the time stamp of last accessing

you can add extra field like page url to store the current page user is viewing (last click).


2. on every page, put a session code. This code update the status of user and the time stamp based on session id. if sessionid not exist, create one. (This is where the complicated work done).

3. to display the user online, simply query the session table to find out.

that's it.
remember, those are just designing.


Life's too short for arguing.

#4 uraniumdeer

uraniumdeer
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 27 June 2006 - 11:57 AM

Thanks a bunch - off to mees around with it then :)

#5 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 27 June 2006 - 12:01 PM

oh yes, i forgot to mention this.

on step 3 when you read out session users, you will compare the timestamp in the table, against the current timestamp. If the difference was too large, i.e. idle time exceeded, delete this user.

and I just though of something else too. You do not need the status field. simply delete the user if he/she exceed the idle time.
Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users