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.
Request.Cookies( cookie )[(key)|**.**attribute]
- 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.
- Domain: Write-only. It specifies the cookie sent only to the requests domain name.
- Expires: It specifies the expiry date of the cookies. If the data is not set, then the cookies will expire after the session ends.
- HasKeys: Read-only. It specifies whether the cookie contains keys or not.
- 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.
- 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”.
Grow with GeeksforGeeks