Hi I am using XAMPP .
I have developed a LOG IN System.
How I can check either User is ONLINE or Not.

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.

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.

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>

Member Avatar for diafol

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'.

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";
    
   }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.