krishna.p Posted January 5, 2009 Share Posted January 5, 2009 Hi Experts, i am new to php. i would like to implement login/logout functionality to my application. In my application, i have to track the login and logout timestamp of an user. When user logins into my application, iam able to track the timestamp and able to update the timestamp into database. However, iam unable to track the logout timestamp. If the user clicks on LOGOUT button, iam able to track the timestamp. but if the user simply closes the application or simly uses Alt+F4 keys iam unable to catch the timestamp. In both these cases, i would like to catch the timestamp and update it into database. Would appreciate if any of you could help me out. Thanks in advance. Thanks, Krishna.P Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/ Share on other sites More sharing options...
Mark Baker Posted January 5, 2009 Share Posted January 5, 2009 You can try using javascript to trap for an onUnload or onBeforeUnload event, and issue a call to the server when it occurs Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729819 Share on other sites More sharing options...
krishna.p Posted January 5, 2009 Author Share Posted January 5, 2009 Thanks for the reply...would appreciate if could give me some code snippets on how to use javascript in this scenario. Thanks.. Thanks, Krishna.P Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729824 Share on other sites More sharing options...
dezkit Posted January 5, 2009 Share Posted January 5, 2009 Isn't javascript client side? Oh and I wouldn't advise you to use javascript because not everyone has javascript enabled (Why do browsers even do such a feature? Gosh.) Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729826 Share on other sites More sharing options...
Mark Baker Posted January 5, 2009 Share Posted January 5, 2009 Isn't javascript client side? Oh and I wouldn't advise you to use javascript because not everyone has javascript enabled (Why do browsers even do such a feature? Gosh.) If you can think of a way of trapping this browser event via PHP, without the need for any javascript or similar client-side logic, then I'd be very much interested in a solution myself! Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729830 Share on other sites More sharing options...
krishna.p Posted January 5, 2009 Author Share Posted January 5, 2009 yes you are right...in many cases, people may not enabling the javascript option in their browsers. in those cases using javascript doesnot solve our problem. how can i catch the event of user closing the application(cliicking on X of window) or Alt+F4... Freaks some more input from you please... Thanks, krishna.P Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729835 Share on other sites More sharing options...
Mark Baker Posted January 5, 2009 Share Posted January 5, 2009 yes you are right...in many cases, people may not enabling the javascript option in their browsers. in those cases using javascript doesnot solve our problem. how can i catch the event of user closing the application(cliicking on X of window) or Alt+F4... Freaks some more input from you please... dezkit has a valid point, but there is only one viable solution for trapping cliicking on X of window or Alt+F4, and that is javascript. It isn't perfect, and won't catch everybody; but the number of users who are using browsers with javascript disabled (or non-existent) is minimal (unless your site is targetting a very minor segment of the web-surfing public). You would also need to trap for when a user session timed out as well, and that would provide an alternative. Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729853 Share on other sites More sharing options...
krishna.p Posted January 5, 2009 Author Share Posted January 5, 2009 i agree with you Mark baker, i completely missed that concept. i.e.. session expiring.. would appreciate if you could give me a code snippet for how to invoke a server call using javascripts onUnload etc.. and how to handle the session expiring...i would like to update a row in the database.. one more quick question is, will this updating of row happens before closure of window. is this(updating) of row) actually possible? Thanks in advance.. Thanks, Krishna.P Link to comment https://forums.phpfreaks.com/topic/139512-how-to-track-the-logout-timestamp-using-php/#findComment-729856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.