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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:42:40+00:00 2026-05-11T12:42:40+00:00

We have a scenario in which we like to detect when the user has

  • 0

We have a scenario in which we like to detect when the user has left our site and immediately expire their .Net session. We’re using Forms Authentication. We’re not talking about a session timeout, which we already have. We would like to know when a user has browsed away from our site, either via a link, by typing in an address or following a bookmark. If they return to our site, even if right away, they will have to log back in (I understand this is not great usability – this is a security requirement we’ve been given by our client).

My initial instinct is that this is either not possible, or that any solutions will be extremely unreliable. The only solutions we’ve come up with are:

  • Add a JavaScript onBlur event handler that tells the server to log out the session when the user leaves the site.
  • Once the user has logged in, check the HTTP referrer to ensure that the user has navigated from within the site.
  • Add AJAX polling back to the server to keep the session refreshed, possibly on a 10-second interval. When the call isn’t received on time the session would end.

The onBlur seems like the easiest, but possibly least reliable method – I’m not sure if it would even work. There are also issues with the referrer method, as the user could type in an address within the site and not follow a link. The AJAX method seems like it would work, but it’s complicated – I’m not even sure how to handle it on the back-end. I’m thinking there might also be scenarios in which that wouldn’t always work.

Any ideas would be appreciated. Thanks.

  • 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. 2026-05-11T12:42:41+00:00Added an answer on May 11, 2026 at 12:42 pm

    I have gone for a heartbeat type scenario like you describe above. Either Ajax Polling or an IFRAME. When the user closes the browser and a certain timeout elapses (10 seconds?), then you can log them out.

    Another alternative would be to have the site run entirely on AJAX. Thus there is only one ‘URL’ that a user can visit and all content is loaded dynamically. Of course you break all sorts of usability stuff this way, but at least you achieve your goal.

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

Sidebar

Ask A Question

Stats

  • Questions 138k
  • Answers 138k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Open up the project file in a text editor or… May 12, 2026 at 7:35 am
  • Editorial Team
    Editorial Team added an answer There are no events in the NetworkStream class (see MSDN).… May 12, 2026 at 7:35 am
  • Editorial Team
    Editorial Team added an answer If you mean take the union of their data, just… May 12, 2026 at 7:35 am

Related Questions

The scenario is that we have a client/server app with the client install being
I am working in a project where database items are not deleted, but only
Application 1 - Opens a SqlConnection and a SqlTransaction against a SQLServer 2005 database
we have this scenario: A server which contains needed data and client component which

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.