Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In login time username is stored in cookie but it expire after some time though i set the expire date 1d my code is below:

HttpCookie cookie = new HttpCookie("User");
cookie["User_Id"] = "abc1"

cookie.Expires = DateTime.Now.AddDays(1d);
HttpContext.Current.Response.Cookies.Add(cookie);
Posted

Try
cookie.Expires = DateTime.Now.AddDays(1);

refer: https://msdn.microsoft.com/en-us/library/ms178194%28v=vs.140%29.aspx#Background[^]
 
Share this answer
 
Hi..friend..Using This Method..
========================================
http cookie simpletesting=new httpcookie(simpletesting);
simpletesting.value=textbox1.text;
simpletesting.expires=datetime.now.addhours(1);
response.cookies.add(simpletesting);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900