title: authCookie not secure in global.asax
body: <p>I have a login problem.</p>
  
  <p>First i am using SSL while logging.</p>
  
  <p>When i log in, i am creating a cookie like this. when i check if it is secure the answer is yes.</p>
  
  <pre><code>FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,                          // version
                                                     UserName.Text,           // user name
                                                     DateTime.Now,               // creation
                                                     DateTime.Now.AddMinutes(60),// Expiration
                                                     false,                      // Persistent 
                                                     role);         // User data
  
                      // Now encrypt the ticket.
                      string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
  
                      // Create a cookie and add the encrypted ticket to the
                      // cookie as data.
                      HttpCookie authCookie =
                                   new HttpCookie(FormsAuthentication.FormsCookieName,
                                                  encryptedTicket);
  
                      if (authCookie.Secure)
                      {
                          new GUIUtility().LogMessageToFile("The cookie is secure with SSL.");
                          // Add other required code here.
                      }
  
                      authCookie.Secure = FormsAuthentication.RequireSSL;
  
                      // Add the cookie to the outgoing cookies collection.
                      HttpContext.Current.Response.Cookies.Add(authCookie);
  
                      // Redirect the user to the originally requested page 
                      Response.Redirect(FormsAuthentication.GetRedirectUrl(UserName.Text,false));
  </code></pre>
  
  <p>then this is redirected to the global.asax page which has this code:</p>
  
  <pre><code>string cookieName = FormsAuthentication.FormsCookieName.ToString();
          HttpCookie authCookie = Context.Request.Cookies[cookieName];
  
          try
          {
              new GUIUtility().LogMessageToFile(cookieName + authCookie.Secure);
          }
          catch (Exception)
          {
              //
          }
  </code></pre>
  
  <p>here i get the cookieName as ".ASPXAUTH" and authCookie.Secure value as False.
  Why is this happening i want the authCookie.Secure value to be true here.</p>
  
  <p>Any suggestions?? thanks</p>
  
  <p>my web config has this:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
          &lt;forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" slidingExpiration="true" timeout="120" path="/" requireSSL="true" protection="All"&gt;
          &lt;/forms&gt;
      &lt;/authentication&gt;
  &lt;httpCookies requireSSL="true"/&gt;
      &lt;authorization&gt;
          &lt;deny users="?"/&gt;
          &lt;!--&lt;allow users="*"/&gt;--&gt;
      &lt;/authorization&gt;
  </code></pre>