Perfidus Posted July 8, 2008 Share Posted July 8, 2008 I have a database where I'm storing the sessionID, User, date and 1 or 0 depending if the session is still alive. I have a function which calculates as well the time an user have been logged and ends the Session after 15 min. The question is that this function is invoked only when user's refreshes or moves around the site, this is not a big matter but the real one comes when the user just closes the window or even the browser... In this case, I would like to know how to set this 1 0 in my DDBB. Maybe some javascript calling a php?? Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/ Share on other sites More sharing options...
ag3nt42 Posted July 8, 2008 Share Posted July 8, 2008 usually in a case of leavin a site... the session relies on a timeout to end the session.. being that php is server side.. i don't think you'll be able to run a session_destroy(); on a event Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584435 Share on other sites More sharing options...
jonsjava Posted July 8, 2008 Share Posted July 8, 2008 seeing how you're storing it in a db, you need to keep the session time to live in there to, and have a cron that runs every 5 minutes or so, that "cleans up" the sessions. Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584436 Share on other sites More sharing options...
Perfidus Posted July 8, 2008 Author Share Posted July 8, 2008 To have this cron that checks for the time the session have already been UP it must be installed on the server, isn't it? What I mean whit this is: Nothing that can just be uploaded trough FTP but an APP that must self-execute?? I do not have permissions to install anything like this on the server... Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584440 Share on other sites More sharing options...
gigas10 Posted July 8, 2008 Share Posted July 8, 2008 Theres a javascript function that detects onwindowclose or something, with that just have a script that detects for that, and say session.destroy Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584447 Share on other sites More sharing options...
Perfidus Posted July 8, 2008 Author Share Posted July 8, 2008 this is what i was talking about!! let me check this out and I will post here what I find... Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584459 Share on other sites More sharing options...
tibberous Posted July 8, 2008 Share Posted July 8, 2008 I won't worry about it. If you tighten security by closing peoples sessions, you'll just piss them off. I stay logged in to everything, all the time, and hate having to reenter passwords - especially now that FF3 screws up and doesn't save anything properly. Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584463 Share on other sites More sharing options...
adam84 Posted July 8, 2008 Share Posted July 8, 2008 Use the 'onwindowclose' event in the <BODY> tag then in the javascript function whatever you name it, you can call a php file using ajax. Link to comment https://forums.phpfreaks.com/topic/113726-solved-closing-sessions-when-user-closes-window/#findComment-584466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.