I am working on an ASP.NET MVC 4
application. I have created few cookies and did not set any expiration time on it. When I am doing a RedirectToAction, all the cookies are getting deleted. I am not sure what I am missing here. Following is the code I wrote to create and access cookies:
Creating cookies:
HttpCookie authorizedCookie = new HttpCookie(AuthCookieName);
authorizedCookie.Value = authorized.ToString();
Response.SetCookie(authorizedCookie);
Accessing Cookies:
authorized = Request.Cookies[AuthCookieName] != null ? System.Convert.ToBoolean(Request.Cookies[AuthCookieName].Value) : false;
When I am trying to access the cookies, the cookie collection is always empty.
Update: I have also tried setting the domain, expiration time, httponly and yet nothing seems to work. When I look at fiddler, the cookies just seems to be deleted immediately after the redirect.