Name
Cookies
Synopsis
HttpCookieCollection = Response.Cookies
The Cookies collection returns an instance
of the HttpCookieCollection
class containing all
cookies sent as a part of the current request. The
HttpCookieCollection
class contains an instance of
the HttpCookie
class for each cookie passed as
part of the client request. The properties of these HttpCookie
instances can be used to access information about the cookie(s). The
Cookies collection of the Response
class supports
the following set of properties:
- AllKeys
Returns a string array of all keys in the collection.
- Count
Returns an integer count of the number of name/value pairs in the collection.
-
Item(
Index|Key
) Returns an instance of the collection class based on the index or passed-in key. This is the default property, which is why calling:
Response.Cookies (
KeyVal
)returns the HttpCookie instance corresponding to
KeyVal
.- Keys
Returns a collection of the keys for the collection.
In addition, the HttpCookieCollection
class
exposes the following methods:
-
CopyTo(
Array
,Index
) Copies the contents of the collection object to the provided
Array
argument, starting at the providedIndex
argument. Note that the array must be dimensioned to a sufficient size to contain the collection before calling CopyTo.-
GetKey(
Index
) Returns a string containing the key corresponding to the provided
Index
argument.
As in classic ASP, the Cookies collection is still implemented as a
collection (in fact, the HttpCookieCollection
class inherits ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.