Alert user when their session is about to expire

Note: Cross posted from Vijay Kodali's Blog.
Permalink

Here is a quick and dirty trick to alert users on session timeout. This is not a perfect solution. But it will give reader an idea to work on...

Some facts before we start:

Session doesn't end

  • When the user closes his browser
  • When the user navigates away from your page
  • When user connection lost.

Session ends, when the server hasn't gotten a request from the user in a specific time (Session timeout value)....Permalink

2 Comments

  • Hi..
    My button does not work in panel...
    It does not get triggered.
    can you help me with it..
    Here is code..
    <cc1:ModalPopupExtender ID="mpe_alert" runat="server"  TargetControlID="pnlAlert"
            OnOkScript="onOK" PopupControlID="pnlAlert" BehaviorID="mpe_alert">
          </cc1:ModalPopupExtender>
          <asp:Panel style='display: none' ID='pnlAlert' runat='server'>
        <table  style='height:100px;background-color:#ffffff;' cellspacing='0' cellpadding='0' width='340' border='0' >
          <tbody>
          <tr>
                   <td  style='width: 200px; color:#ffffff; height:20px; background-color:#003366'>
                                           Security Warning
                   </td>
          </tr>
          <tr>
                   <td>
                   </td>
          </tr>
          <tr align="center">
                   <td>
                       Your login session is about to expire.Do you want to extend it?
                   </td>
          </tr>
          <tr>
                   <td>
                       <table cellpadding="0" cellspacing="0" width="100%" border="0">
                        <tr align="center">
                           <td>
                           <a href="../AdminLogin.aspx" >Logout</a>
                           <asp:Button ID="btnOK" runat="server" Text="Continue" OnClick="btnContinue_Click" />
                           <asp:Button ID="btnCancel" runat="server" Text="Logout" OnClick="btnLogout_Click" />
                           </td>
                        </tr>
                       </table>
                   </td>
          </tr>
          </tbody>
          </table>
          </asp:Panel>
          I want to extend session when user clicks continue button and want to logout when user clicks logout..

  • This code only works for fix timeout value , what about sliding expiration ?

Comments have been disabled for this content.