When the users login , i want to show the status is online in php. What is the code? Thanks!

7 Years
Discussion Span
Last Post by rayidi

Use flag variable in the user's profile table of your database. When the user login to the system update the field with value 1 and update 0 when he/the log out from the system. Then display a green light icon if that field in database is 1 else show gray light icon wherever you required.

Edited by karthik_ppts: n/a

Votes + Comments
Helpful reply

when they login, add true into the online row in the database, then just check if online is true in php.


Hi dude

Add a field called 'status' in users table. where users table containing all data of user.

UPDATE 'status' to 'online' when user login.. this code will be placed after validating the username and password..

// Eg: When you starting a session for the user write this update

When a user trying to logout UPDATE 'status' to 'offline'.. this code will be placed beside the session_destroy() statement

If you have any doubts IM me on [snipped]

Thanks & Regards
Radhakrishna Rayidi
PHP Developer

Edited by Ezzaral: Snipped email and self-promotional links. Please keep it on site.

Votes + Comments
Helpful post

What is flag variable?

Flag variable is just a field of your table in database. Krish explained clearly about this in previous post.

Edited by karthik_ppts: n/a


Thankyou karthik, But you wrote good answer also.. but here users wants explanation..
Any way nice meeting you..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.