Solved

how to automatically logout when close the browser in php?

Posted on 2014-11-27
3
206 Views
Last Modified: 2014-12-11
This was already asked but the answer was incorrect.   I had always assumed that when the browser is closed and the client computer is turned off that the session will not persist.   This is not true.   I know because I've experienced it.   I turned off my computer and when I come back the session variable is still set.   Not only was my browser closed and my PC turned off but Apache which was running on my computer was turned off also.   What I've found is that if I close firefox without closing the tab that was open that the variable stays set.  If I close the tab first and then close the variable it is unset.    I can't find a solution or even an acknowledgement that this is an issue.     I hear tales that you can have the session variables drop after some period of inactivity however I'm not sure how to get the timer to start once inactivity has set in.
0
Comment
Question by:vrosas_03
3 Comments
 
LVL 35

Accepted Solution

by:
Kimputer earned 250 total points
ID: 40468939
What is your current session.gc_maxlifetime setting in php.ini?
0
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 250 total points
ID: 40469019
use meta no-cache...

when browser is closed, crashes, pc shuts down, session will not expire immediately, but will do after timeout (default is 15-20 min)

you can try turning off page cashing or try using some cookies...
0
 

Author Closing Comment

by:vrosas_03
ID: 40494633
This is the maxlifetime:
session.gc_maxlifetime = 1440
I thought it would close the session with the browser.  I ended adding something to check if there has been any activity and if there hasn't to log the user out.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now