Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



Remarks: ASP Request Object Cookies Collection

Access the subkeys of a cookie dictionary by including a value for key. If a cookie dictionary is accessed without specifying a key, all 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.

An iterator can be used to cycle through all cookies in the Cookie collection, or all 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 attribute.



ContentsPreviousNextIndex