HttpCookieCollection.Item[] Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the cookie with the specified name from the cookie collection. This property is overloaded to allow retrieval of cookies by either name or numerical index.
Overloads
Item[Int32] |
Gets the cookie with the specified numerical index from the cookie collection. |
Item[String] |
Gets the cookie with the specified name from the cookie collection. |
Item[Int32]
Gets the cookie with the specified numerical index from the cookie collection.
public:
property System::Web::HttpCookie ^ default[int] { System::Web::HttpCookie ^ get(int index); };
public System.Web.HttpCookie this[int index] { get; }
member this.Item(int) : System.Web.HttpCookie
Default Public ReadOnly Property Item(index As Integer) As HttpCookie
Parameters
- index
- Int32
The index of the cookie to retrieve from the collection.
Property Value
The HttpCookie specified by index
.
Examples
The following example stores the name of the first cookie as a string variable (index = 0) in a cookie collection.
String CookieName = MyCookieCollection[0].Name;
Dim CookieName As String = MyCookieCollection(0).Name
See also
Applies to
Item[String]
Gets the cookie with the specified name from the cookie collection.
public:
property System::Web::HttpCookie ^ default[System::String ^] { System::Web::HttpCookie ^ get(System::String ^ name); };
public System.Web.HttpCookie this[string name] { get; }
member this.Item(string) : System.Web.HttpCookie
Default Public ReadOnly Property Item(name As String) As HttpCookie
Parameters
- name
- String
Name of cookie to retrieve.
Property Value
The HttpCookie specified by name
.
Examples
The following example gets the cookie with the name "LastVisit" and extracts its value.
String str;
str = Request.Cookies["LastVisit"].Value;
Dim str As String
str = Request.Cookies("LastVisit").Value