System.Web Namespace HttpRequest Class
Gets a collection of cookies sent by the client.
[ VB ]
Public ReadOnly Property Cookies As HttpCookieCollection
[ C# ]
public HttpCookieCollection Cookies {get;}
[ C++ ]
public: __property HttpCookieCollection* get_Cookies ( );
[ JScript ]
public function get Cookies ( ) : HttpCookieCollection;
An HttpCookieCollection object representing the client's cookie variables.
The Request.Cookies collection enables you to retrieve the values of the cookies sent in an HTTP request. This collection contains all the key=value
pairs transmitted by the client to the server in the Cookie header.
The following example [ C# ] shows how you can dynamically retrieve ( and display into an HTML table ) the name, value, expiration date, and security parameter of each HTTP cookie sent by the client.
<table class="data" width="90%">
<tr>
<th>Name</th>
<th>Value</th>
<th>Expires</th>
<th>Secure</th></tr>
<% foreach ( string key in Request.Cookies ) { %>
<tr>
<td><%= key %></td>
<td><%= Request.Cookies[ key ] .Value %></td>
<td><%= Request.Cookies[ key ] .Expires %></td>
<td><%= Request.Cookies[ key ] .Secure %></td></tr>
<% } %>
</table>
Show me
Response.Cookies HttpRequest Members