eldan88 Posted March 31, 2013 Share Posted March 31, 2013 Hey I was wondering if there is a way where I can write a code that will find the user's previous session if they deleted thier cookie, or if the cookie has been expired in the middle of a session. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/276356-is-it-possible-to-find-a-previous-session-if-cookie-has-been-deleted/ Share on other sites More sharing options...
kicken Posted March 31, 2013 Share Posted March 31, 2013 With traditional file-based sessions you could get the session_save_path directory and scan through the files searching for some particular string. If you find the string, then the session ID is in the name of the file, just extract it and restore it (using session_id prior to session_start). If you are using some other session handler (such as memcache or mysql) you'll need to figure out something else out by looking into how the data is actually saved. Quote Link to comment https://forums.phpfreaks.com/topic/276356-is-it-possible-to-find-a-previous-session-if-cookie-has-been-deleted/#findComment-1422128 Share on other sites More sharing options...
eldan88 Posted March 31, 2013 Author Share Posted March 31, 2013 With traditional file-based sessions you could get the session_save_path directory and scan through the files searching for some particular string. If you find the string, then the session ID is in the name of the file, just extract it and restore it (using session_id prior to session_start). If you are using some other session handler (such as memcache or mysql) you'll need to figure out something else out by looking into how the data is actually saved. I'm using session_start() is that considered traditional file-based sessions? Quote Link to comment https://forums.phpfreaks.com/topic/276356-is-it-possible-to-find-a-previous-session-if-cookie-has-been-deleted/#findComment-1422160 Share on other sites More sharing options...
kicken Posted March 31, 2013 Share Posted March 31, 2013 You use session_start either way. If you did not set your own session handler using session_set_save_handler then you most likely are using file-based sessions. Quote Link to comment https://forums.phpfreaks.com/topic/276356-is-it-possible-to-find-a-previous-session-if-cookie-has-been-deleted/#findComment-1422165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.