I have a cookie which is set when a user accesses the page /auth/ of my MVC3 application.
When a user posts the form data back to the server I modify the cookie by changing the value it has assigned. I then use Response.Cookies.Set(mycookie);
to change the cookie to the value of mycookie.
The issue I am having is that when the page is first loaded 'get' request the cookie appears as a cookie. Upon receiving the post response back the cookie now appears as a session with a completely different expiry date.
CODE::
[HttpGet]
public ActionResult Auth()
{
var cookie = Request.Cookies.Get(login_cookie);
if (cookie == null || string.IsNullOrEmpty(cookie.Value))
{
Response.Cookies.Add(new HttpCookie(login_cookie) { Expires = DateTime.Now.AddMinutes(5), Value = "0", HttpOnly = true, });
}
.....
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(Login loginform)
{
int attempts = 0;
HttpCookie login_cookie_data = Request.Cookies.Get(login_cookie);
....
Response.Cookies.Set(login_cookie_data);
return View();
}
Resolved
Issues was with machine. I restart and it sorted all issues.