title: Classic ASP: Multiple ASPSESSIONID in cookies
body: <p>I have a problem with a classic asp page and I just cannot solve it since 3 days.</p>
  
  <p>The page is working with Sessions - sometimes it happens that the ASPSESSIONID cookie is set twice in the Request.ServerVariables("HTTP_COOKIE"). This causes the ASP-Page to jump between the two Sessions when the page is refreshed. </p>
  
  <p>I have written an Test page which outputs the current SessionId, the Server Software and the HTTP_COOKIE value.</p>
  
  <p>Sample Output:</p>
  
  <hr>
  
  <p>Session ID: 308542840</p>
  
  <p>Session Timeout: 20 minutes</p>
  
  <p>Server Software: Microsoft-IIS/6.0</p>
  
  <p>HTTP_COOKIE: ASPSESSIONIDQCBATRAD=MBHHDGCBGGBJBMAEGLDAJLGF; ASPSESSIONIDQCCDTTCB=PGHPDGCBPLKALGGKIPOFIGDM </p>
  
  <hr>
  
  <p>Why are there two ASPSESSIONIDs? 
  When I refresh the page then it randomly outputs one of the two Session IDs.</p>
  
  <p>Here is a screencast which shows the problem in IE9:
  <a href="http://prinz-alexander.at/asp_test.avi" rel="noreferrer">http://prinz-alexander.at/asp_test.avi</a></p>
  
  <p>This error often occurs in ie8 and ie9.</p>
  
  <p>Just do the following to recreate the Problem:</p>
  
  <ol>
  <li>Completely close IE8 or IE9</li>
  <li>Start IE8 or IE9 and open <a href="http://www.pfiffikus.at/pfiffikus/tests/" rel="noreferrer">http://www.pfiffikus.at/pfiffikus/tests/</a></li>
  <li>Immediatly after the page is loaded refresh the page mutiple times</li>
  </ol>
  
  <p>If you repeat this steps then randomly (not always) the HTTP_COOKIE is populated with two different ASPSESSIONIDs.</p>
  
  <p>The asp test file is only outputing the mentiod values, nothing else is happening in the source code.</p>
  
  <p>This is the code of the asp test file:</p>
  
  <pre><code>&lt;% If trim(Session("test_val")) = "" Then
       Dim my_num
       Randomize
       number = Int((rnd*1000))+1
       Session("test_val") = number
     End If
  %&gt;
  
  &lt;b&gt;Session ID:&lt;/b&gt;
  &lt;% response.write(Session.SessionId) %&gt;&lt;br /&gt;&lt;br /&gt;
  
  &lt;b&gt;Session("test_val"):&lt;/b&gt;
  &lt;% response.write(Session("test_val")) %&gt;&lt;br /&gt;&lt;br /&gt;
  
  &lt;b&gt;Session Timeout:&lt;/b&gt;
  &lt;% response.write(Session.Timeout) %&gt; minutes&lt;br /&gt;&lt;br /&gt;
  
  &lt;b&gt;Server Software:&lt;/b&gt;
  &lt;% response.write(Request.ServerVariables("SERVER_SOFTWARE")) %&gt;&lt;br /&gt; &lt;br /&gt;
  
  &lt;b&gt;HTTP_COOKIE:&lt;/b&gt; &lt;% response.write(Request.ServerVariables("HTTP_COOKIE")) %&gt;
  </code></pre>
  
  <p>How can i avoid multiple ASPSESSIONIds in cookies?</p>
  
  <p>Thanks for any help!</p>