Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm pretty sure you need to use the username as the first parameter in SetAuthCookie - it's how the FormsAuthentication module knows who the user is.</p> <p>SetAuthCookie creates an auth ticket under the hood. Have you tried making your own auth ticket? It will let you store extra data on it.</p> <p>It's explained here: <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx#Y1368" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.aspx#Y1368</a></p> <p>basically you do this:</p> <pre><code>FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30), isPersistent, //true or false webkey, //Custom data like your webkey can go here FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); </code></pre> <p>This explains how you read the data back <a href="http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.userdata.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.security.formsauthenticationticket.userdata.aspx</a></p> <pre><code>FormsIdentity id = (FormsIdentity)User.Identity; FormsAuthenticationTicket ticket = id.Ticket; string webkey = ticket.UserData; </code></pre> <p>Edit: Also, the auth cookie is httponly by default. You can use a firefox plugin like live headers to verify that it is created.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload