Jump to content

Logged in or not


hazz995

Recommended Posts

I want to display a field that says if a user is logged on or not, also depending on how long the user is inactive for then they will be identified as "logged out" (if the user comes back they are still logged in with the saved session though)

Basically if the user has been inactive for 15 Min's then they are identified to other people as 'not online'.

I'm not quite sure where to start with this so I just need a little nudge to get me started.

 

Just the way to do it would be good enough, try to limit the amount of code because I want to try doing it myself, not saying I wouldn't mind some code to start me off though ;)

Link to comment
Share on other sites

Add a database field to the users table called, "Last Activity" if this value is less than 15 minutes show them as being online / logged in. If not show them as being logged out.

I have a Last Login field which is a TIMESTAMP, so I'll just have to copy that field to Last Activity.

I'll have to do some lookup on comparing time since I have no idea how.

Link to comment
Share on other sites

Alright I'm stuck on this one :/

My poor attempt at trying to +15 mins onto the users last active time, basically how I'm trying to get it to work: if users last active time + 15 mins is higher than current time then they are logged on, else logged off. I tried a few other methods but nothing worked, the lastactive time is in the same format as $date also. (Y-m-d h/i/s)

$date = date("Y-m-d h/i/s");
if ($user['lastactive']+15 <=$date)

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.