5 Replies - 1472 Views - Last Post: 24 July 2010 - 02:16 AM Rate Topic: -----

#1 Senseye  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 65
  • Joined: 02-March 09

PHP: User online?

Posted 23 July 2010 - 03:00 PM

Helllo all!

I have an Authentication System working on sessions.

Do you have any suggestions about making an User Online or Not function?

This post has been edited by Senseye: 23 July 2010 - 03:02 PM

Is This A Good Question/Topic? 0
  • +

Replies To: PHP: User online?

#2 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 541
  • View blog
  • Posts: 1,708
  • Joined: 08-November 08

Re: PHP: User online?

Posted 23 July 2010 - 03:07 PM

I'd recommend looking into writing a custom session handler. Then you could track sessions from a database ;)

This post has been edited by Valek: 23 July 2010 - 03:07 PM

Was This Post Helpful? 2
  • +
  • -

#3 Senseye  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 65
  • Joined: 02-March 09

Re: PHP: User online?

Posted 23 July 2010 - 04:55 PM

Thanks Valek!
Was This Post Helpful? 0
  • +
  • -

#4 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 541
  • View blog
  • Posts: 1,708
  • Joined: 08-November 08

Re: PHP: User online?

Posted 23 July 2010 - 08:56 PM

You're welcome. I think you're going to love all of the extra things a custom session handler will enable you to do. It and a custom exception handler (or multiple, if you're making more than one kind of exception) are two things I'd highly advise for almost any application requiring user authentication (and exception handlers for pretty much any application in general).
Was This Post Helpful? 0
  • +
  • -

#5 shezzy  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 194
  • Joined: 28-January 07

Re: PHP: User online?

Posted 23 July 2010 - 09:21 PM

Personally, I followed a method i found on this site previous that basically added a "timestamp" field in a login table for users. When they log in or traversing your site, store the current time then when you check to see how many users are online you basically run a query to find all users whose last timestamp is greater then NOW()-5minutes ago . Also, when you create a logoff link make sure it runs a query to update the users timestamp to something like NOW()-6minutes so when it looks for users currently online within the last 5minutes(active or logged in) it wont be included...hope that helps

cheers :bananaman:
Was This Post Helpful? 0
  • +
  • -

#6 mahcuz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 143
  • View blog
  • Posts: 213
  • Joined: 03-June 10

Re: PHP: User online?

Posted 24 July 2010 - 02:16 AM

View Postshezzy, on 24 July 2010 - 03:21 AM, said:

Also, when you create a logoff link make sure it runs a query to update the users timestamp to something like NOW()-6minutes so when it looks for users currently online within the last 5minutes(active or logged in) it wont be included...hope that helpsName($name) { $this->name = $name; }
public function get

cheers :bananaman:


Or just set a flag in your database that the user is logged out, then you can ignore the users that have this flag.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1