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 !!!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.