Creating a Cookie on the User’s machine for 1 months using C#.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 809
Write below query:-
HttpCookie UsrDet = new HttpCookie();

//Add the values into cookie
UsrDet["Name"] = "John";
UsrDet["Desig"] = "Project Manager";
UsrDet["Age"] = "30";
UsrDet["Sal"] = "0.0";
UsrDet["Place"] = "UK";

//Set the cookie expire details
UsrDet.Expires = DateTime.Now.AddDays(30);

//Add to the collection
Response.Cookies.Add(UsrDet);

Comments or Responses

Login to post response