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

  • Home
  • SEARCH
  • 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 8615191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:18:51+00:00 2026-06-12T05:18:51+00:00

Many sites ( Bank webSite for example) – implement log-out + 1 minute warning

  • 0

Many sites ( Bank webSite for example) – implement log-out + 1 minute warning before session is about to expire.( 20 minutes)

(this topic is not discussed much – the only question ive seen is with using asp.net membership – which I don’t use)

each user will have a session["lastActionTime"]

this session will be update to current Time when :

  • Page is loaded
  • Ajax request has executed ( due to user action)

Now – when a page loads , I set the session value. (lets say 19:00)

Also , for every ajax request (my site doesnt create postbacks – only ajax jquery) – I use an ASHX handler with IRequiresSessionState which updates the session to current Time.

I use something like this :

jQuery(document).ajaxStart(function(){
    gotoHandlerAndUpdateSessionTime();
})

Now -the part for 1 minute before warning message ( ” your session is about to expire “) :

Every ajax return event or page load event – I activate in javascript : setInterval with [sessionTime-1] minutes ( 20-1=19). ( and of course – cancelling all prev setIntervals… )

now when the event (setInterval) occurs – it is 1 minute before expiration time : (19 min)

I display a warning div , and the user can choose exit or stay .

question :

1) what if the user didnt press nothing on the warning div , How (after 1 minute from displaying the div) will I log him out ? Should I open a setTimeout of 1 minute when displaying the div and then (if nothing pressed) to log him out ?

2) is it the right way of doing it ?

3) Shouldn’t there be cookies in this whole weird story ? 🙂

(please – no membership – or Forms authentication).
I’m tagging this question also as PHP since I know it is relevant to php programmers as well and I would like to hear from their knowledge.

  • 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-06-12T05:18:52+00:00Added an answer on June 12, 2026 at 5:18 am

    Royi, to answer both of your questions, I would say YES. I’ve built these several times (usually with Forms Auth), but basically you have a timer that counts down to show the first warning, and then another timer that counts down and gives the user X seconds to answer. I usually put the X second count down on the warning message so they can see how much time they have left. If they don’t answer in the allotted time, a call gets made to Logout.ashx (or whatever) that destroys the session and then the javascript can redirect them back to the login page. I hope that helps.

    Regarding your third question, as long as you’re tracking the session you shouldn’t really need cookies. Just do a session_destroy() in PHP or Session.Abandon() in C# when the javascript timer counts down.

    Here’s some code I’m using on one of my sites (might not be the cleanest, but you get the idea):

    var timeoutPolled = 0;
    var timeoutSeconds = 10;
    var countDownCounter = 61;
    var timeoutBetweenPolls = 5000;
    var stopCountDown = false;
    
    function InitializePollTimer(timeoutMinutes) {
        timeoutSeconds = timeoutMinutes * 60;
    
        StartPollTimer();
    }
    
    function StartPollTimer() {
        setTimeout(PollForTimeout, timeoutBetweenPolls);
    }
    
    function PollForTimeout() {
        timeoutPolled++;
    
        if ((timeoutPolled * timeoutBetweenPolls) > 1 * (timeoutSeconds * 1000)) {
            $("#timeoutDialog").dialog({
                autoOpen: false,
                bgiframe: true,
                resizable: false,
                height: 250,
                draggable: false,
                modal: true,
                zindex: 99999999,
                position: 'top',   
                open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },       
                buttons: {
                    "Continue using Website?": function() {
                        StopCountDown();
    
                        $.ajax({
                            type: "GET",
                            url: "RefreshSession.aspx",
                            cache: false
                        });
    
                        $(this).dialog("close");
    
                        timeoutPolled = 0;
                        StartPollTimer();
                    },
                    "Logout": function() {
                        Logout();
                    }
                }
            });
    
            $("#timeoutDialog").dialog("open");
    
            countDownCounter = 61;
    
            CountDown();
        }
        else {
            StartPollTimer();
        }
    }
    
    function CountDown() {
        if (stopCountDown) {
            stopCountDown = false;
        }
        else {
            countDownCounter--;
            $("#countdownTimer").html(countDownCounter);
    
            if (countDownCounter > 0) {
                setTimeout(CountDown, 950);
            }
            else {
                Logout();
            }
        }
    }
    
    function StopCountDown() {
        stopCountDown = true;
    }
    
    function Logout() {
        window.location.href = 'Logout.aspx';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am .net beginner. I have gone through many sites before asking here. I
Many many sites uses this technique (facebook, google as well) For example, open facebook.com
Many sites implement different methods and I am having a hard time deciding on
On many sites I saw printed out my current city where I am (eg
How do I go about learning web typography? I see many sites using nice
I have found many sites that describes PRG, but no simple PHP code example.
I am about to migrate a large web project (many sites using common data)
I have one question about how to handle a webform sites, i have many
Many sites show a Back to top link in their footer. Others, even worse,
I've noticed many sites are able to use a username or page title as

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.