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

Recommended Answers

All 6 Replies

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.

commented: Helpful reply +0

What is flag variable?

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

commented: Helpful post +4

What is flag variable?

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.