5
Contributors
5
Replies
11
Views
7 Years
Discussion Span
Last Post by elisha24
0

The best way is to just on login, send a session cookie to the user or a cookie that expires when the user leaves the website. Then when the user accesses a page with the cookie then a `online` column in the mysql user database will turn into the current timestamp value. Then a cron job checks if that timestamp subtract the current timestamp is greater than 150 seconds and if that is true then php will replace the timestamp with 0 making the user offline. Hope you could understand that.

0

You might want to increase the 150 seconds if, like this site, it takes longer than that to read the content of one of the pages, or perhaps the page has media like an flash movie player.

0

i have great solution for ur question-- all u have to do is this

make a column in the database where u pick username and password to login-- name it status_flag with default value 0
now write a querry wen username and password matches

update status flag =1 where user name is "------"

and use session
and wen u will logout then update again the status to 0

i have its script u can contact me at <snip>

Edited by nav33n: Email address snipped. Keep it on the site. Read forum rules.

1

i have great solution for ur question-- all u have to do is this

make a column in the database where u pick username and password to login-- name it status_flag with default value 0
now write a querry wen username and password matches

update status flag =1 where user name is "------"

and use session
and wen u will logout then update again the status to 0

i have its script u can contact me at <snip>

Seen this before, but a problem arises when a user leaves the site without logging out. You need to run a script with a timestamp of some description. A cron job to check the last page impression is one way - although cron jobs may be a little 'expensive'.

0

u can use this script like this use timestamp session if user leave without logout

function removeInactiveUsers(){
      if(!TRACK_VISITORS) return;
      $timeout = time()-USER_TIMEOUT*60;
      $q = "update FROM ".TBL_ACTIVE_USERS." WHERE timestamp < $timeout";
    
   }

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.