Hello Everyone,
I am saving Session values in cookies with following code :
- HttpCookie AlvloginCookie = new HttpCookie("AlvLogin");
- //Set the Cookie value.
- AlvloginCookie.Values["Name"] = Session["Name"].ToString();
- AlvloginCookie.Values["UserAuthKey"] = Session["UserAuthKey"].ToString();
- AlvloginCookie.Values["Email"] = Session["Email"].ToString();
- AlvloginCookie.Values["UserId"] = Session["UserId"].ToString();
- AlvloginCookie.Path = Request.ApplicationPath;
- AlvloginCookie.Expires = DateTime.Now.AddDays(365);
- Response.SetCookie(AlvloginCookie);
- Response.Cookies.Add(AlvloginCookie);
Using that cookies on page using following code :
Request.Cookies["UserId"].Value;
The cookies are getting created in browser, but it does not last long for 365 days.
It is getting expired after couple fo hours.
Anything I missed or any other suggestion would be really appreciated
Thank you in advance

Darshan ShahRank #1,135 · 1.6K reputationPosted Aug 14, 2020, 7:17 AM EDT
Farhan AhmedRank #73 · 25K reputationPosted Aug 14, 2020, 8:50 AM EDT
Navaneeth KrishnanRank #1,172 · 1.5K reputationPosted Aug 14, 2020, 8:17 PM EDT
Laxmidhar SahooRank #383 · 6.6K reputationPosted Aug 14, 2020, 11:22 PM EDT
Guest UserRank #2,192 · 643 reputationPosted Aug 15, 2020, 9:48 AM EDT
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Aug 15, 2020, 6:16 PM EDT