saikatbasu Posted March 15, 2007 Share Posted March 15, 2007 Hi, I am developing a website in PHP and MySQL as a backend. Poeple has to login to avail of the services. I am storing the users ID along with IP addresses who have logged in. And deleting the entry when the user clicks signout. At a certain page I want to check whether the people who have logged in are still online or not. If they clicks signout the entry is deleted from the database and I will get accurate data. But incase the user does not clicks signout and just closes the page, then the web page will be showing the user as online while actually he is offline. :-\ Is there any way to retrieve the IP addresses of the users who are connected to the site(browsing the site) dynamically.? Or any other solution to handle this situation... Thanks in advance... Saikat. Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/ Share on other sites More sharing options...
flappy_warbucks Posted March 15, 2007 Share Posted March 15, 2007 what i done when i had to ovecome the problem is in the SQL database create a table called SESSION_USERS then on every click there would be a statement in the page putting the time and date into the SQL. in addition to this i made a seperate function what was invoked on every single click, that would take the time and then calculate how long each and every person in the SESSION_USERS table had been on using the time and date stamp from the last click, if the had been on for longer the 20 minutes it would mark it as inactive (i never delete record out of a SQL, i keep then incase i need them fro whatever reason in the future) so it worked like, the person would log on and then if they closed the window as long as someone was on the site clicking away, if no activity in 20min then effectivly they where automaticly logged off sorry i forgot to add that in the table session_users you would keep track of the session_id() IP address, username time, and date. Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/#findComment-207865 Share on other sites More sharing options...
monk.e.boy Posted March 15, 2007 Share Posted March 15, 2007 you could set up a cron job to scan the database every 10 minutes and log anyone out who has been inactive for more than 10 minutes. This would reduce server load a little. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/#findComment-207894 Share on other sites More sharing options...
flappy_warbucks Posted March 15, 2007 Share Posted March 15, 2007 you could set up a cron job to scan the database every 10 minutes and log anyone out who has been inactive for more than 10 minutes. This would reduce server load a little. monk.e.boy i was under the impression that only worked on UNIX platforms i.e. linux... if that works on win32 systems i would be a very happy bunny indeed! does that work on win32?!? Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/#findComment-207900 Share on other sites More sharing options...
monk.e.boy Posted March 15, 2007 Share Posted March 15, 2007 scheduled tasks. http://www.google.co.uk/search?num=100&hl=en&q=windows+scheduled+task&btnG=Search&meta= This should work in the same way. You may need to look at running a php script from the command line (search this forum for examples) monk.e.boy Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/#findComment-207929 Share on other sites More sharing options...
saikatbasu Posted March 22, 2007 Author Share Posted March 22, 2007 Thanks a lot u guys... These solutions will cost a little bit overhead. But it will solve the purpose... I was wondering if there is something similar to global.asa in ASP, where one can write modules which gets fired on session start and end. But as far as my knowledge goes PHP does not has any concept of global.asa. If anyone knows how to create global.asa in PHP please let me know.... Thanks once again... Link to comment https://forums.phpfreaks.com/topic/42818-retrieving-connected-clients-ips/#findComment-212595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.