title: ASP.NET session - How can I tell if a session is new due to expiration or initial visit?
body: <p>We have a page of search results which the user can hit in several ways.  90% of the ways will set up a 'Search Criteria' session object, which the results page will use to retrieve the search results.</p>
  
  <p>When the session object isn't found, we will typically show the user an 'invalid search' message, and give them a link to the main search page.</p>
  
  <p>The exception is the case where the user hits a webpage which has the search results page as it's default page (we use .NET's themes to provide private labels for our site, skinning it with our affiliates' colors and logos).  If the search results page is the default page for the site, there is a special search that is preformed when there is no session criteria.</p>
  
  <p>This is working fairly well in our testing, but there is an edge case we would like to handle: When a session expires while someone is on the search results page (having come from the search page) and they then click on the next page of results, they will get this special search instead of the 'expired session' message.</p>
  
  <p>This is the basic format we're using, where searchCriteria is set from session.</p>
  
  <pre><code>if (searchCriteria == null)
  {
      if (/*Check if this is the default url for this site*/)
      {
        //Preform special search
      }
      else
      {
        //Display 'session expired message'
      }
  }
  </code></pre>
  
  <p>Is there a way we can check Session in the inner if block to see if the user's session is new due to expiration of an existing?  Or do browsers just throw away the session cookies when they expire?</p>
  
  <p>Is there a browser difference?  Do some return the expired session cookie to the server, while other's delete them on expiration?  Or is it consistent?</p>