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

Related Questions

Scenario: I have a login page which uses ajax to validate a user and
We have a scenario in which several threads call a static method like the
I have a scenario in which I'm serving a file from codebehind. which file,
I have a scenario in which I have REST API which manages a Resource
I have implement a scenario which involves two way communication between child and parent
I have a performance run scenario which calls cd %AUTORUN_DIR% call abc.bat cd %AUTORUN_DIR%
I have a very simple scenario which I cannot get to work. I am
I am new to RSpec and I have a test scenario in which I
I have a scenario where i have one control, which is using another control
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.

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.