Skip to content
Related Articles

Related Articles

ASP Request.Cookies Collection
  • Last Updated : 24 Mar, 2021

Basically Cookies are small files that are stored on a user’s computer. They are used to hold a modest amount of data specific to a particular client and website and can be accessed either by the web server or by the client computer.  

The Request.Cookies Collection is used for returning the value of the collection of the cookies. If the specified cookie does not exist, it is created. If the cookie exists, it takes the new value, and the old value is discarded. 

Syntax:

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

    Parameter:

  • Name: It specifies the name for the Cookies.
  • Key: It is not an optional parameter represents a key value for the cookies.
  • Attribute: It specifies the information about the cookies . The attribute parameter can be one of the following.
    1. Domain: Write-only. It specifies the cookie sent only to the requests domain name.
    2. Expires: It specifies the expiry date of the cookies. If the data is not set, then the cookies will expire after the session ends.
    3. HasKeys: Read-only. It specifies whether the cookie contains keys or not.
    4. Path: Write-only. If specified, the Cookie is sent only to requests to this path. If this attribute is not set, the application path is used.
    5. Secure: write-only. It represents that the cookies are secured.
  • Value: It defines a value that is assigned to the key or attribute.

Example: Basically “Request.Cookies” command is used to get a cookie value. Below code illustrates that how to return the value of cookies named as “firstname”.




<%
Response.Cookies("site")="GeeksforGeeks"
sname=Request.Cookies("site")
response.write("Grow with " & sname)
%>

Output:

Grow with GeeksforGeeks
My Personal Notes arrow_drop_up
Recommended Articles
Page :