Skip to content
Related Articles

Related Articles

ASP Response.Cookies Collection

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 03 Feb, 2021

Basically Cookies are small files which are stored on a user’s computer. It is 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 Response.Cookies Collection is used for setting the value of 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. 




  • 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 requests domain name.
    2. Expires: It specifies the expiry date of the cookies. If the data is not set, then the cookies will expiry 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 is secured.
  • Value: It defines a value which is assigned to the key or attribute.

Example 1: Below code illustrates how to create cookies having named “website” and assigned the value “GeeksForGeeks” to it. 


Example 2: Below example demonstrate how you can set a value for a cookie and assign values to its attributes.

 Response.Cookies("Type") = "fruits"  
 Response.Cookies("Type").Expires = "July 31, 2001"  
 Response.Cookies("Type").Path = "/"  

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!