Hello All,
I have one overlay div inside a condition.
If Cookies[“User”] is null then I show overlay div having two radio buttong and one submit button.
When user select radio option and click submit button,when by ajax call ,I am calling an action ,
Which sets cookies.
I have putted Overlay div inside layout page,so for every call it checkes for session.
My issue is : First time after setting cooikes, it’s not persist for second time.
Below is my method which sets cookies:
public ActionResult SaveUserTypeCookies(string usertype, string returnUrl)
{
if (Request.Cookies["User"] != null)
{
HttpCookie cookie = Request.Cookies["User"];
cookie.Values["UserType"] = usertype;
cookie.Expires = DateTime.MaxValue;
Response.SetCookie(cookie);
}
else
{
HttpCookie cookie = new HttpCookie("User");
cookie.Values["UserType"] = usertype;
cookie.Expires = DateTime.MaxValue;
Response.Cookies.Add(cookie);
}
return Redirect(returnUrl);
Below is my contion for overlay div:
@if ((Request.Cookies["User"]== null))
{
}