cloudll Posted March 1, 2012 Share Posted March 1, 2012 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? Link to comment https://forums.phpfreaks.com/topic/258029-displaying-an-image-according-to-session/ Share on other sites More sharing options...
spiderwell Posted March 1, 2012 Share Posted March 1, 2012 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. Link to comment https://forums.phpfreaks.com/topic/258029-displaying-an-image-according-to-session/#findComment-1322671 Share on other sites More sharing options...
cloudll Posted March 1, 2012 Author Share Posted March 1, 2012 Thats a good idea, do you know how I could remove the database entry if the user timed out rather than logged out? Link to comment https://forums.phpfreaks.com/topic/258029-displaying-an-image-according-to-session/#findComment-1322674 Share on other sites More sharing options...
dragon_sa Posted March 1, 2012 Share Posted March 1, 2012 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. Link to comment https://forums.phpfreaks.com/topic/258029-displaying-an-image-according-to-session/#findComment-1322677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.