0

How to destroy an active session on closing the browser window without using cookies in php?

Hii there, I am developing a web app, in which I have given login and logout facility. I have used a submit button , that when triggered, the session desstroyed. But while closing the browser window , I am unable to do so.... Please anyone provide me the right way to do so... Thank You !!!!

8th Jul 2017, 2:42 PM
ShßvÄm KûmÄr Ðwïvëðß
ShßvÄm KûmÄr Ðwïvëðß - avatar
1 Answer
+ 3
Check the user input password against your db (hashed/encrypted) credential entries. If match is found define a valid_session, a timeout_interval, and a session_start with php Session variables. Upon loading any page, check the value of the valid_session, if the timeout interval is expired, change the value of the valid_session variable (to redirect the user to the login page), else reset your timeout interval by assigning the current timestamp to the session_start variable. Upon exiting the browsers, session variables won't be kept, thus redirecting the user to the login page on next attempt to open the webpage. https://www.w3schools.com/php/php_sessions.asp
8th Jul 2017, 5:52 PM
seamiki
seamiki - avatar