title: Session Timeout .NET
body: <p>I searched but I dont`t find any specific answer for this question.
  How I can get value in server how much time left, before session expires?
  My session settings:</p>
  
  <p>//timeout for example 10 min.</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt; &lt;forms name=".ASPXAUTH_External" loginUrl="Authentication/Unauthorized.aspx" protection="All" timeout="10" path="/" slidingExpiration="true" defaultUrl="~/Pages/home.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/&gt;
  &lt;/authentication&gt;
  &lt;sessionState mode="InProc" timeout="10"&gt;
  &lt;/sessionState&gt;
  </code></pre>
  
  <p>I get initial value (it will get 10*60 = 600 seconds):</p>
  
  <pre><code>SessionStateSection sessionSection = (SessionStateSection)WebConfigurationManager.GetSection("system.web/sessionState");
  countdown.Text = sessionSection.Timeout.TotalSeconds.ToString();
  </code></pre>
  
  <p>But when session time left less then half and user do some action. I get initial value 600, but it is not equal for left session time, because "slidingExpiration" <strong>add some time</strong> (I don`t know how much), but not resets session left time to starting 10 min point.</p>
  
  <p><strong>How can I get remaining session time until expiration?</strong></p>