Home > Code > C# > Create a cookie on the user’s machine for 50 days using C#

Create a cookie on the user’s machine for 50 days using C#

by Spidy   on Feb 28, 2011   Category: C#   |  Views: 1024    |  Points: 25   |  Silver 


below sample code used to create a cookie on the users machine.

//Create cookie 
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(50);
//Add to the collection
Response.Cookies.Add(UsrDet);





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts