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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:30:22+00:00 2026-05-15T23:30:22+00:00

There are various ways to handle session timeouts, like meta refreshes javascript on load

  • 0

There are various ways to handle session timeouts, like “meta refreshes” javascript on load functions etc.

I would like something neat like: 5 minutes before timeout, warn the user…

I am also contemplating keeping the session open for as long as the browser is open(still need to figure out how to do it though… probably some iframe with refreshing).

How do you handle session timeouts, and what direction do you think i should go in?

  • 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-15T23:30:23+00:00Added an answer on May 15, 2026 at 11:30 pm

    The best approach to handle sessions timeouts.

    I say that there is 2 basic cases.
    One is when the users enter little or no data, and just read reports, or do small thinks with his mouse. In this case there is not easy way to inform him that the session is going to expire. If you going to check the time left for the session calling the code behind, then automatically you update the session. Then if you have a timer to count down the session, then maybe the user have open a new tab of your web and the session is going to expired but not the time you have note with javascript and the user receive wrong message.

    So for me, when the user enter little or no data, just let the session expired, if he lose one click, it will do it again later.

    Second is when the user need to enter many data, that some time can take time, a long text for example, to write it and fix it. In this case I use the below technique and I am not let the session go out.

    How to keep the session open as long as the browser.

    Here is a very nice and simple technique, I use an image that I make an reload of it before the session is timeout using JavaScript.

    <img id="keepAliveIMG" width="1" height="1" src="/img/ui/spacer.gif?" /> 
    
    <script language="javascript" type="text/javascript"> 
        var myImg = document.getElementById("keepAliveIMG");
    
        if (myImg){
            window.setInterval(function(){
                  myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
                }, 6000);
        }   
    </script> 
    

    In a third case, you can do this. We care if the session is expired only on post back. When the user have enter some data and on the post back the application is redirect him on the login page and the post lost.

    In this third case you can capture the post data and saved them until the user re-login. You capture the post data on global.asax on the

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    

    This is the function that called before the redirect to the login page, and there you see if you have post data and the use required to login, you save that post data, ether to a new redirect page, ether to the server (maybe on session, maybe on your temporary database).

    Now after the user is login again, you redirect him again to the last page with the saved post data, and the user is continue as it is.

    The only trick here is to make a middle page, that render the form with the last posted data and an automatically redirect javascript call.

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

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • 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 You're writing a query and then asking that query to… May 16, 2026 at 8:37 am
  • Editorial Team
    Editorial Team added an answer Check out this Ruby interface to the HTML Tidy library. May 16, 2026 at 8:37 am
  • Editorial Team
    Editorial Team added an answer This will return you top 10 users: SELECT u.*, (… May 16, 2026 at 8:37 am

Trending Tags

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

Top Members

Related Questions

Consider that there are 100 plus ways of interrupts occuring from various sensors. There
There are various ways to maintain user state using in web development. These are
There are various ways to take screenshots of a running application in Windows. However,
There are several different ways I can initialize complex objects (with injected dependencies and
I am concerned whether Rails can handle the types of complex aggregations that are
I'm building an app which is going to have to handle and store a
I'm currently trying to understand the intrinsics of iterators in various languages i.e. the
So I'm working through a bit of a problem, and some advice would be
I'm building a text input field specialized for entering and editing times. One of
I'm re-designing an app I inherited that sends digital photos from a laptop to

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.