Tracking which users are logged in (via database)

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Tracking which users are logged in (via database)

Post by Luke »

I know I saw a topic about this and I looked around for it, but couldn't find it. I have a user privelege/admin panel for my file management system. I would like this panel to display which users are logged in. I really don't know where to start. So far all I've got is a "logged_in" column in my users table.

Where do i go next?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Usually, with my user driven sites, I will have a boolean field within the users table that turns on when they are logged in. That way I can see at any time who is logged in by querying the user table where user_logged_in = TRUE or something like that.
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

I store my sessions data in the database, so I just look at the last time the session was updated, and if it was more recent than some arbitrary amount (say, 5 mins), I assume the user is logged in.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

GM wrote:I store my sessions data in the database, so I just look at the last time the session was updated, and if it was more recent than some arbitrary amount (say, 5 mins), I assume the user is logged in.
Nice... thanks!
Post Reply