Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to automatically logout when close the browser in php?

Posted on 2014-11-27
3
212 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
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…

840 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