RTS Posted October 3, 2006 Share Posted October 3, 2006 Is there a way to have a database automatically be updated when the session times out? Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/ Share on other sites More sharing options...
MCP Posted October 3, 2006 Share Posted October 3, 2006 yes, but you'll have to write your own session handling functions for all session related options. Seehttp://ca.php.net/manual/en/function.session-set-save-handler.phpThere's even an example there for file-based sessions which you might want to extend. You'll want to put your database update in the _close and/or _gc functions. Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/#findComment-103469 Share on other sites More sharing options...
RTS Posted October 5, 2006 Author Share Posted October 5, 2006 well, I realized there is a problem with doing that on my site, so I have another question. Is there a way to update the database when a user leaves the site? that would work better. Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/#findComment-104049 Share on other sites More sharing options...
Hi I Am Timbo Posted October 5, 2006 Share Posted October 5, 2006 not without javascript. The only action is when a php script is called. Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/#findComment-104058 Share on other sites More sharing options...
RTS Posted October 5, 2006 Author Share Posted October 5, 2006 hmmmmm... could someone explain how to do what was suggested first? the tutorial confused me, and I didnt get what I was supposed to do... Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/#findComment-104068 Share on other sites More sharing options...
Hi I Am Timbo Posted October 5, 2006 Share Posted October 5, 2006 I've never done this before, but it looks like you define functions with the same names as these:session_set_save_handler("open", "close", "read", "write", "destroy", "gc");Then when named action occurs, it runs that function. You would have to include this file on all of your pages, likely before you do session_start(); Link to comment https://forums.phpfreaks.com/topic/22928-update-mysql-database-when-session-ends/#findComment-104072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.