I developed website with ASP.NET. Now I make an authentification.
Authorization is made by another web service. If the answer from web-service is success, I create a ticket:
var ticket = new FormsAuthenticationTicket(1, param.Login, DateTime.Now, DateTime.Now.AddDays(1), false, string.Empty, FormsAuthentication.FormsCookiePath);
var encTicket = FormsAuthentication.Encrypt(ticket);
var AuthCookie = new HttpCookie(FormsAuthentication.FormsCookieName)
{
Value = encTicket,
Expires = DateTime.Now.AddDays(1)
};
Response.Cookies.Set(AuthCookie);
This code added authentification cookie. But if I add the next string after previous code:
Response.Redirect("<redirect address>");
cookie is disappeared after redirect.
Why it's happened?
web.config part of authentification here:
<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH" loginUrl="~/login.ashx" />
</authentication>
It may happen that the cookie data being associated with the cookie has exceed the maximum allowed size in its encrypted format. Unencrypted, the data will not be too large.
Large size of the cookie may result in dropping of the cookie from the response header. Below fixes are worth trying:
This POST gives a good information on Cookie size.