Jump to content

If user is online Green Dot to be shown next to user profile name.


nileshjoshi

Recommended Posts

hi all , am new to php and  want to show If user is online[login] Green Dot to be shown next to user profile name.....and if user logout then nothing.....and other login user also see the green dot on user profile which is online......can i need to create a table in my database?

please give me some solution...

 

thanks in advance !!!

 

You've posted this in the wrong forum, I'm moving it for you.

 

Typically you'd store the timestamp each time the user loads a page. Then if the last page load was within X minutes, they're considered "online".

OK - Chump time!

Example table contents

USER table
userid | username | firstname | lastname | etc

PAGELOAD table
userid | pageid | loadtime

When you list the users then use a query like this so you can tell who is online, assuming if they have not reloaded a page for 15 mins they are offline
 

SELECT u.firstname, u.lastname,
    (p.loadtime > NOW() - INTERVAL 15 minute) as online
FROM user u
    INNER JOIN pageload p USING (userid)

    
If they are online, the online column returned will be 1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.