title: Classic ASP / End of session redirect
body: <p>I want to automatically redirect to the login page when the users session has expired.</p>
  
  <p>I have been using the following code in an include file that sits at the top of every page in my application:</p>
  
  <pre><code>Session.Timeout = 60
  Response.AddHeader "Refresh", CStr(CInt(Session.Timeout + 1) * 60)
  Response.AddHeader "cache-control", "private"
  Response.AddHeader "Pragma","No-Cache"
  Response.Buffer = True
  Response.Expires = 0
  Response.ExpiresAbsolute = 0
  
  If Session("accountID") = "" Then
      Response.Redirect("http://www.mydomain.com/")
  End If
  </code></pre>
  
  <p>This works but there is very slight bug. Every now and then the page will refresh even though the session is still alive and it seems that it refreshes before the 60 minutes is up!</p>
  
  <p>Can anybody see what the problem is or can you suggest a different method?</p>