title: Secure cookies flag always getting lost in first session after resetting IIS
body: <p>Looking for solution for ASP.NET_SessionId should always be secure flag true when request is from secure connection.</p>
  <p>Below Steps are done to achieve -</p>
  <ol>
  <li>Created MVC Project</li>
  <li>Added below code under Global.asax.cs</li>
  </ol>
  <pre class="lang-cs prettyprint-override"><code>protected void Session_Start(object sender, EventArgs e)
     {
        Response.Cookies[&quot;ASP.NET_SessionId&quot;].HttpOnly = true;
        if (Request.IsSecureConnection) {
            Response.Cookies[&quot;ASP.NET_SessionId&quot;].Secure = true;
         }
     }
  </code></pre>
  <p>It works fine gives expected result. Here's is screenshot for secured flag.</p>
  <p><strong>Screenshot</strong>
  <img src="https://i.imgur.com/eZSPzoW.png" alt="" /></p>
  <p>To Reproduce Issue :</p>
  <ol>
  <li><p>Delete Existing Cookies</p>
  </li>
  <li><p>Reset IIS</p>
  </li>
  <li><p>Load website in SSL</p>
  </li>
  </ol>
  <p><strong>4) Cookies of first session gets created is always remain Unsecure</strong>
  After the first session all session cookies remain secure.</p>
  <p><strong>Here is screenshot for SSL request with unsecured cookies.</strong><br />
  <img src="https://i.imgur.com/CKjNhyY.png" alt="" /></p>
  <p>May know the how to make sure cookies get remain secure while SSL request. Also it must be by code only.</p>