Jump to content

Displaying an image according to session


cloudll

Recommended Posts

Hi guys, I have followed a tutorial and made a members only area using sessions. The user can upload an image and which gets renamed as their username. I was hoping to display all the users images that are logged in. I know how to do it with a single image by just setting the img src as the session username but I don't know how I would display multiple images if more than one person were logged in. Is it even possible?

I am pretty sure that there isnt a way to collectively 'show all sessions' in php, but I might be wrong.

The alternative would be to have another table in the database that you update with users when the login and logout (or timeout) so you keep a tally of who is online, and do it that way.

 

Back in the day of classic asp you could use application level variables that were great for keeping track of things like this, I am not sure if php has such things.

Have a function that updates the users session time by say 15mins for example on all the logged in pages, then either have a cron job check the table for any expired session times every 5mins for example and remove them, or also put that into the functions of the logged in pages, the preference would be for the cron job.

You could also use that time for if they come back to the browser after 15mins to auto log them out and redirect to a login script again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.