Comprehensive, categorized, searchable collection of links to ASP & ASP.NET resources...deloittes.NET Directory - Click for Demo!!
Our Directory

Applications
ASP.NET Directory
Books & Media
Community
Components
Other ASP Sites
Reference Material
Software & Server
Tutorials & Code
Web Site Hosts

Expand Directory...
Personlise Results...

Newsgroups

Participate in over
100 ASP & ASP.NET related newsgroups right here @ Fuzzy Software...

.NET Framework
- .net.faqs
- .net.framework
- .net.general
- .net.setup
- .net.scripting
- .net.xml

Web Services
- aspnet.webservices
- msdn.soaptoolkit
- msdn.webservices

SQL Server
- sqlserver.setup
- sqlserver.prog...
- sqlserver.tools

Classic ASP
- asp.db
- asp.general
- asp.components

Scripting
- scripting.jscript
- scripting.remote
- scripting.vbscript
- scripting.wsh

All newsgroups...

ASP Built-in
Objects Reference


Application Object
ObjectContext Object
Request Object
Response Object
Server Object
Session Object

Personalise Fuzzy
Make Homepage
Link To Fuzzy
Bookmark This Page

Add our directory to your site in less than
2 minutes...














Whats New!
The Cookies collection enables you to retrieve the values of the cookies sent in an HTTP request.

Syntax

Request.Cookies(cookie)[(key)|.attribute] 
 

Parameters

cookie
Specifies the cookie whose value should be retrieved.
key
An optional parameter used to retrieve subkey values from cookie dictionaries.
attribute
Specifies information about the cookie itself. The attribute parameter can be the following.
Name Description
HasKeys Read-only. Specifies whether the cookie contains keys.

Remarks

You can access the subkeys of a cookie dictionary by including a value for key. If a cookie dictionary is accessed without specifying key, all of the keys are returned as a single query string. For example, if MyCookie has two keys, First and Second, and you do not specify either of these keys in a call to Request.Cookies, the following string is returned.

First=firstkeyvalue&Second=secondkeyvalue
 

If two cookies with the same name are sent by the client browser, Request.Cookies returns the one with the deeper path structure. For example, if two cookies had the same name but one had a path attribute of /www/ and the other of /www/home/, the client browser would send both cookies to the /www/home/ directory, but Request.Cookies would only return the second cookie.

To determine whether a cookie is a cookie dictionary (whether the cookie has keys), use the following script.

<%= Request.Cookies("myCookie").HasKeys %> 
 

If myCookie is a cookie dictionary, the preceding value evaluates to TRUE. Otherwise, it evaluates to FALSE.

You can use an iterator to cycle through all the cookies in the Cookie collection, or all the keys in a cookie. However, iterating through keys on a cookie that does not have keys will not produce any output. You can avoid this situation by first checking to see whether a cookie has keys by using the .HasKeys syntax. This is demonstrated in the following example.

<% 
'Print out the entire cookie collection.
For Each cookie in Request.Cookies
  If Not cookie.HasKeys Then
    'Print out the cookie string 
%>
    <%= cookie %> = <%= Request.Cookies(cookie)%>
<%
Else
  'Print out the cookie collection
  For Each key in Request.Cookies(cookie)
%>
  <%= cookie %> (<%= key %>) = <%= Request.Cookies(cookie)(key)%>
<%
  Next 
End If
Next 
%> 
 

Examples

The following example prints the value of myCookie in a Web page.

Here is the value of the cookie named myCookie: 
<%= Request.Cookies("myCookie") %> 
 

Applies To

Request Object

See Also

ClientCertificate, Form, QueryString, ServerVariables

 






Ektron web editor and content management software

Receive all the latest quality ASP
& ASP.NET content direct to your inbox. Sign-up to our newsletter.




DevCity.NET

FreeBugTracking.com

ActiveServerPages.ca

Ascenvia.net

ASPWarp

More partners...

Ektron web editor and content management software
  5825 ASP & ASP.NET resources in over 450 categories and growing daily...
Fuzzy Software - asp / asp.net resources, tutorials, code, scripts, applications, components, newsgroups, hosts and much more... Sitemap 0 1 4