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 6697613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:28:51+00:00 2026-05-26T06:28:51+00:00

I have a nice LogOut button on the menu of my PHP app, but

  • 0

I have a nice LogOut button on the menu of my PHP app, but some people don’t use it, they just quit the browser.

Is there any way that I can detect quiting the browser and/or closing the last tab with my App open? (I realize that it won’t handle browser crash, but it’s better than I have now & covers 99% of cases).

I undestand that I can’t use JavaScript since the DOM won’t let my JS be aware of other brower tabs and windows.

I used a timer based solution, but a single user set the timeout to 999999 minutes and the number of simultaneous users to 1, then closed his browser & locked himself out.

But, what about another way? Think laterally, folks. Can I push a cookie when the user opens a new tab with a page from my app? And then remove the cookie when the user wishes to close the tab? And check if I am remvoing the last cookie & inform the server to treat this as logout?

If not cookies is there some other method? (Use Ajax on page open & close and the server can decide if the last tab has closed?)

  • 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-26T06:28:51+00:00Added an answer on May 26, 2026 at 6:28 am

    How about catching the unload event of the web page, so that when it unloads, it uses ajax to call a script on the server. This script will then store the time that the browser calls it.

    If within 20 seconds, the browser accesses another page that uses the same session, this will mean that the user is just navigating around your site. then you can safely unset that time stored from the ajax call.

    At the server end, have a cron job that runs every minute (5 if you are worried about resources) that checks if any of the session has the unload time set, and that the unload time is longer than 25 seconds. If so, then it means the user has closed the browser, tab, or has navigated away from your app. It should be save to do any clean up or logging out for that browser then.

    You might need to adjust the timing depending on how the internet/server speed and how fast the page refreshes when the users navigate around.

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

Sidebar

Related Questions

I have a nice Logout button on the menu of my PHP app, but
I have a nice DataGridView showing what is basically some kind of log data
I have this nice little MSBuild-based daily build setup that I use on my
I would like to have a nice easy to use file upload system on
In my project (iPhone app) I have a nice webview to allow users to
IE have nice feature: if you right-click on some link you will see an
I don't have much experience with web.config files but what I am trying to
I don't have nice short code examples to display with this post. I'm running
I'm using devise for user auth, but I have nice mockups for the signup,
I have, I believe, a simple problem, but I don't know how to solve

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.