Hello Everyone,
I am facing issue with saving persistent cookie for 30 days, when i am creating cookie it is creating successfully but when i logout of my application or close the browser window, cookie is cleared off and cannot use anymore.
if (Request.Browser.Cookies)
{
if (!string.IsNullOrEmpty(MachineName))
{
HttpCookie reqCookies = Request.Cookies["UserInfo"];
if (reqCookies != null)
{
MachineName = reqCookies["MachineName"].ToString();
}
}
}
HttpCookie reqCookies = Request.Cookies["UserInfo"];
if (reqCookies == null)
{
HttpCookie UserInfo = new HttpCookie("UserInfo");
UserInfo["MachineName"] = MachineName[0];
UserInfo.Expires.AddDays(30);
//Response.Cookies.Add(UserInfo);
HttpContext.Response.SetCookie(UserInfo);
}
Any help is Appreciated!