C# Cookie HttpOnly
Description
Cookie HttpOnly
Determines whether a page script or other
active content can access this cookie.
Syntax
Cookie.HttpOnly
has the following syntax.
public bool HttpOnly { get; set; }
Example
The following example displays the properties of cookies returned in a response.
using System.Net;
using System;/* w w w . ja v a2 s .c o m*/
public class CookieExample
{
public static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://google.com");
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
foreach (Cookie cook in response.Cookies)
{
Console.WriteLine("Cookie:");
Console.WriteLine(cook.HttpOnly);
}
}
}
The code above generates the following result.