title: Forms Authentication - Require SSL - Setting Authentication Cookie Fails
body: <p>I'm trying to configure my environment such that the authentication cookie can only be accessible through HTTPs (securing it from XSS attacks). I read several articles and I reached the conclusion that I should set the requireSSL attribute to "true"</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
    &lt;forms name="someName" loginUrl="~/login" timeout="40" protection="All" slidingExpiration="true" defaultUrl="~/index" requireSSL="true" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>The problem is that when I'm trying to set the Authentication cookie, it throws an exception.</p>
  
  <pre><code>FormsAuthentication.SetAuthCookie(username, false);
  </code></pre>
  
  <p><strong>Exception:</strong></p>
  
  <p>The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.</p>
  
  <p><strong>Stack trace:</strong>    </p>
  
  <p>System.Web.HttpException: The application is configured to issue secure cookies. These cookies require the browser to issue the request over SSL (https protocol). However, the current request is not over SSL.</p>
  
  <p>at System.Web.Security.FormsAuthentication.SetAuthCookie(String userName, Boolean createPersistentCookie, String strCookiePath)</p>
  
  <p>The problem occurs on my local machine (even though it's configured for HTTPs access) and on the live server as well (which is also on HTTPs)</p>
  
  <p>Can anyone help me with this issue? Thanks.</p>