标签:
void Page_Load(object sender, EventArgs e) { // Create a new HttpCookie. HttpCookie myHttpCookie = new HttpCookie("LastVisit", DateTime.Now.ToString()); // By default, the HttpOnly property is set to false // unless specified otherwise in configuration. myHttpCookie.Name = "MyHttpCookie"; Response.AppendCookie(myHttpCookie); // Show the name of the cookie. Response.Write(myHttpCookie.Name); // Create an HttpOnly cookie. HttpCookie myHttpOnlyCookie = new HttpCookie("LastVisit", DateTime.Now.ToString()); // Setting the HttpOnly value to true, makes // this cookie accessible only to ASP.NET. myHttpOnlyCookie.HttpOnly = true; myHttpOnlyCookie.Name = "MyHttpOnlyCookie"; Response.AppendCookie(myHttpOnlyCookie); // Show the name of the HttpOnly cookie. Response.Write(myHttpOnlyCookie.Name); }
标签:
原文地址:http://www.cnblogs.com/xiaosa-blog/p/4318908.html