View Full Version : Determine if User is on Page

11-20-2007, 11:05 PM
I've created two small image 'button's of green and red.

I'd like to be able to have the image show green when the user is on a specific page (viewing a game) and red when they are not present.

Is there a simple way to determine when a user is on a specific page?

11-20-2007, 11:15 PM
Store the page in the session, or database if you have a login system.

11-21-2007, 12:32 AM
Store the page in the session, or database if you have a login system.

How would do that with a Session? I only want it to look at one specific page. I'm getting better at php, and thinking things through, but not sure on this one. It may be simplier than I'm making it to be though.

11-21-2007, 03:16 AM
Perhaps something like this - checking if a session has been set.

if($_SESSION['user_status'] == "online"){
user is online...
user is not online

You could incorporate it into a database too, and have the database updated when the user is online and when they leave the page.

Velox Letum
11-21-2007, 04:41 AM
If you mean for others viewing the user's status, then you'll have to store it in a database. You can pretty easily store sessions in a database (see articles below) and then query the sessions table for status. I'm sure you can come up with the logic to set a session variable for in game or not and the code to deserialize the session information.