Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5965051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:32:37+00:00 2026-05-22T19:32:37+00:00

I have a PHP app which requires log in, offers a log out option

  • 0

I have a PHP app which requires log in, offers a log out option and force logs off users who have been inactive for X minutes.

But, if I log in, close my browser and re-open it, the $_SESSION variables still exists.

What’s the general practise here? Should I want to prevent this and, if so, how?

Something in me just wants to treat closing the browser as logout … on the one hand, it’s a secure app (since it requires login) but a non-tech user might reasonably expect that if they close the whole browser then no one can see their private data. Otoh, if the browser crashes and the user restarts it, he might hope to pick up where he left off …

What do others do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:32:38+00:00Added an answer on May 22, 2026 at 7:32 pm

    PHP sessions work by saving a cookie to the user’s browser containing the ID of the session on the server. Therefore PHP sessions work exactly like ordinary cookies do.

    If you close your browser, cookies are persistent. The server doesn’t know what instance of the browser the user is using, whether the browser has restarted, or even if the computer has restarted.

    Providing a log-out button is the most usual practice here, but if for some reason you require the user to be logged out when the browser closes, you will have to implement something client-side, as the browser doesn’t send any signal to the server when it closes.

    If you are concerned about security – i.e. you are programming a highly secure application such as a payment gateway – you can follow the practice of bank websites or other payment gateways;

    When the user returns to the site, they are still logged on, but when they try to perform any action that will affect the logged-in user, re-authenticate with another password screen, or ask for some memorable information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a PHP app with a dynamic URL scheme which requires characters to
I have a LAMP (PHP) web app which need to interface with programs on
I have a PHP app that creates a CSV file which is forced to
I have written a web app in PHP which makes use of Ajax requests
I have been working on a small php app (400K total). But in the
I have an existing large(ish) PHP web app (using Apache and MySQL) which now
I'm working on a PHP app which requires various settings to be stored in
Does anyone use PhoneGap? I have a php app which uses ajax to receive
I have an app which stores some data in .php files in /library/ directory,
I got to work on PHP app which requires a webservice call to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.