How to create a persistent cookie
I want to create a persistent cookie, how to create it.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
vijayPosted Jul 27, 2012, 9:57 AM
Refer the below link to create persistent cookies.
http://www.dotnetcode.in/2011/08/store-user-name-in-cookies-using-aspnet.html
Sachin KaliaPosted Jul 16, 2012, 2:48 AM
The easist way to create persisted cookie is under here:
You can also refer the link given below for more detail:
http://stackoverflow.com/questions/3140341/how-to-create-persistent-cookies-in-asp-net
Chees DotNet :)
Satyapriya NayakPosted Jul 16, 2012, 2:18 AM
Please refer the below links
http://www.codeproject.com/Articles/31914/Beginner-s-Guide-To-ASP-NET-Cookies
http://ashrafur.wordpress.com/2008/01/11/persistent-and-non-persistent-cookies-in-aspnet/
http://www.java2s.com/Tutorial/ASP.NET/0240__Cookie/Createapersistentcookie.htm
Thanks
Praveen VRPosted Jul 16, 2012, 1:31 AM
You can do this with the following code:
HttpCookie _cookie1 = new HttpCookie("LocalComputer");
_cookie1.Values.Add("username", username);
_cookie1.Expires = DateTime.Now.AddMonths(1);
Response.Cookies.Add(_cookie1);
And you can call this cookie with the following code:
if (Request.Cookies["LocalComputer"] != null)
{
HttpCookie _cookie = Request.Cookies["LocalComputer"];
string username=_cookie["username"].toString();
}