alluoshi Posted February 12, 2009 Share Posted February 12, 2009 Hello, I am working on a session-based multi-user web application (through Apache, php and mysql). When a user logs in, a new session starts. I would like to write a program to save this information: 1- the username who joined (originally created in mysql) 2- session id 3- session start date 4- session end date (when the user logs out, or when the browser is closed) so when the session ends, I want this information to be saved in mysql database (the username will be saved in Table "users" and the session_id, session_start_time and session_end_time will be saved in Table "Sessions" Any idea about how to solve this problem? Link to comment https://forums.phpfreaks.com/topic/144958-session-start-and-session-end-events/ Share on other sites More sharing options...
rhodesa Posted February 12, 2009 Share Posted February 12, 2009 #1-#3 are easy to do, but #4 isn't possible as you describe. you can track when the user clicks Log Out, and record that. but as far as when the browser is closed, you will never be notified about that. you can though, track the last time the user did anything, then either use that or have a cronjob that goes through and records a 'session end date' for anything that has been stale for say...20 minutes Link to comment https://forums.phpfreaks.com/topic/144958-session-start-and-session-end-events/#findComment-760672 Share on other sites More sharing options...
alluoshi Posted February 12, 2009 Author Share Posted February 12, 2009 Thank you. what about if I have 50 sessions at the same time (50 users)? How can I handle this information (about users and sessions) until this information is saved permanently in the database Link to comment https://forums.phpfreaks.com/topic/144958-session-start-and-session-end-events/#findComment-760727 Share on other sites More sharing options...
rhodesa Posted February 12, 2009 Share Posted February 12, 2009 are you not using PHP Sessions already? http://us2.php.net/manual/en/intro.session.php http://devzone.zend.com/node/view/id/646 Link to comment https://forums.phpfreaks.com/topic/144958-session-start-and-session-end-events/#findComment-760756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.