ASP Object: Request.Cookies

Source: Internet
Author: User
Tags object http request key client
Cookie|cookies|object|request|cookie

Cookies

The Cookies collection allows the user to retrieve the value of the cookie sent in the HTTP request.

Grammar

Request.Cookies (cookie) [(key) |. Attribute  

Parameters

Cookies
Specifies the cookie whose value you want to retrieve.
Key
An optional parameter that retrieves the value of a subkey from the cookie dictionary.
Attribe
Specifies information about the cookie itself. Its property parameters are as follows: The name Description HasKeys read-only. Specifies whether the cookie contains keywords.

Comments

You can access the child keywords of the cookie dictionary by including a key value. If key is not specified when accessing the cookie dictionary, all keywords are returned as a single query string. For example, if MyCookie has two keywords, first and Second, and does not specify any of these keywords when calling Request.Cookies, the following string is returned.

If the client browser sends two cookies with the same name, then Request.cookie returns one of the deeper path structures. For example, if you have two cookies with the same name, but one of the path properties is/www/and the other is/www/home/, and the client browser sends two cookies to the/www/home/directory at the same time, Request.cookie will return only the second C Ookie.

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

False  

If MyCookie is a cookie dictionary, the previous assignment is TRUE. Otherwise, FALSE.

You can iterate through all the cookies in the cookie collection or all the keywords in the cookie. However, traversing the keyword through a cookie without a keyword does not produce any output. You can avoid this situation by first checking the cookie for keywords using haskeys syntax. This is demonstrated in the following example.

  

Example

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

This is the cookie value named MyCookie:   

Apply to

Request Object



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.