Name
Cookies
Synopsis
HttpCookieCollection = Request.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).
As in classic ASP, the Cookies collection is still implemented as a
collection (in fact, the HttpCookieCollection inherits from the .NET
NameObjectCollectionBase
class), but rather than a
collection of string keys and string values, the ASP.NET
implementation is a collection of string keys and objects (instances
of the HttpCookie
class). Individual cookies are
retrieved into variables of type HttpCookie, providing access to the
cookies’ values through class properties.
Dictionary-style cookies (cookies with more than one value) are
accessible through the Values property of the
HttpCookie
class, which returns a
NameValueCollection containing the cookie subkeys and values. You can
also retrieve individual values by their key with the following
syntax:
HttpCookie.Values("keyname
")
Parameters
-
HttpCookieCollection
An Object variable of type HttpCookieCollection.
Example
The example retrieves the collection of cookies from the Cookies property and writes out the key and value of each, along with any subkeys of dictionary cookies:
Sub Page_Load( ) Dim Counter1, Counter2 ...
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.