Reputation: 449
I have the following code:
var httpCookie = context.HttpContext.Request.Cookies[".ASPXAUTH"];
This works in Firefox. [".ASPXAUTH"] is listed and found. However in Chrome and IE9 it is missing and thus httpCookie is null.
Why is this and how can I resolve this please?
Many thanks in advance.
Upvotes: 0
Views: 3133
Reputation: 38618
To get the cookie of the authentication of your application, you could try something like this:
HttpCookie appCookie = context.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
to Decrypt it, you could use:
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(appCookie.Value);
// you can access all properties using the 'ticket' object.
string cookikePath = ticket.CookiePath;
DateTime expiration = ticket.Expiration;
bool expired = ticket.Expired;
bool isPersistent = ticket.IsPersistent;
DateTime issueDate = ticket.IssueDate;
string name = ticket.Name;
string userData = ticket.UserData;
string version = ticket.Version;
Upvotes: 3