- How to create a Session Timer Script -

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
DoppyNL

Post by DoppyNL » Fri Nov 01, 2002 10:07 am

You can use javascript to call a page wich will remove them when they leave your site, but not all users got javascript or have it disabled so you can't trust that for 100%.

I think the best way to do it is to store a date+time of the last page a user has requested, you can easily add this to the table "logstatus".
Then you can simply run a delete query before you show wich users are online and remove entry's wich are 30min or older.

Greetz Daan

Jay

Post by Jay » Fri Nov 01, 2002 2:05 pm

Just to add to DoppyNL, make a table that stores a user's status, or whether they're online. Every time they access a new page, update the time in the page. Every time the table is queried for display to you, delete any entries older than X minutes, and you'll have your list of current users!

Jay

Post by Jay » Sun Nov 03, 2002 11:36 am

Store all the times as a timestamp in the table (which will update itself if you don't enter a value specifically). On your query you can delete records which have a timestamp < NOW()-20 minutes. Have a look in the MySQL manual (under chapter 6.4 I think) for the functions you can use.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests