Alert user before session expires, option to renew session
<p>I am setting session time in web config. I also have a javascript for detecting session timeout and letting the user know.</p>

<p>I would like to be able to alert the user 30 sec or a min or more before session timeout with a popup and to give them the opportunity to extend it or cancel and just let it timeout. Can this be done? I have tried to use various methods on the internet but none seem to work. They all require i download something and i dont want to have to do that.</p>

<pre><code> &lt;script type="text/javascript"&gt;

  var sessionTimeout = "&lt;%= Session.Timeout %&gt;";

  function DisplaySessionTimeout() {

  sessionTimeout = sessionTimeout - 1;

   if (sessionTimeout &gt;= 0)

      window.setTimeout("DisplaySessionTimeout()", 60000);

   else
   {
   alert("Your current Session is over due to inactivity.");
    }
   }


&lt;/script&gt;
</code></pre>

<p>I am also checking for timeout in code behind and rediecting but thinking about just doing it in javascript.</p>

<pre><code>protected void Page_Init(object sender, EventArgs e)
    {
        CheckSession();
    }


    private void CheckSession()
    {
        if (Session["ASP.NET_SessionId"] == null)
        {
           // Session.RemoveAll();
          Response.Redirect("Home.aspx");
        }
    }
</code></pre>
