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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:09:05+00:00 2026-05-17T23:09:05+00:00

I have a web site (written in PHP) that my users need to log

  • 0

I have a web site (written in PHP) that my users need to log into, and I want to be sure that they log out when they’re done. So, I have a JavaScript method that deletes the PHP session cookies, and I want to call that method (a) right before the user either closes the browser window (i.e., the DOM Window object) or (b) points their browser to a site outside of my domain. Part (a) is pretty simple using the Window.onclose method, but I can’t figure out how to do part (b). The problem is that I can’t get any of the Window events to distinguish between when the user is leaving my domain and when he’s going to a different page in my domain. I’ve seen this on some web sites (like, banking web site for example) but does anyone know how I’d actually implement it?

  • 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-17T23:09:06+00:00Added an answer on May 17, 2026 at 11:09 pm

    This blog post is about just that.

    If you’re using prototype, the code will look something like this. (taken from blog post)

    staying_in_site = false;
    
    Event.observe(document.body, 'click', function(event) {
      if (Event.element(event).tagName == 'A') {
        staying_in_site = true;
      }
    });
    
    window.onunload = popup;
    
    function popup() {
      if(staying_in_site) {
        return;
      }
      alert('I see you are leaving the site');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web site in asp.net that uses a master page. In this
I have a web site that is a customer to customer (C2C) service. Example,
I have a web site that I administer that uses Apache 2.0 on the
I have a prototype website written in PHP. Lately i've rewritten code to separate
I have a website cgi-bin program that is written in c++. Unfortunately the website
I have a web site using apache httpd as the server and mysql as
I have a web site which I download 2-3 MB of raw data from
I have a web site running via IIS7 on Vista. The site is running
I have written web apps with JSP in the past. Now, I'm getting started
I have a webapp written in PHP using a MySQL database backend. This question

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.