Sets or retrieves the value of a collection of cookies.
Cookies derived from the Request object retrieve the values sent by the client browser to the server. The client browser sends the values during an HTTP request.
Cookies derived from the Response object create a new cookie if the specified cookie does not exist. If the cookie exists, it takes the new value and resets the old value.
All the properties are applicable both to the Request and the Response objects.Methods that are applicable only for the Response objects are:
All cookies must be created before the first output is sent to the browser.
Returns the total number of Cookie objects in the collection.
object.Count
Long.
Read-only.
Determines whether the specific cookies collection contains more Cookie objects.
object.HasMoreElements
Boolean.
Read-only.
Adds a new Cookie object to the Cookies collection.
object.Add(
Name As String,
Value As String)
String. Sets the name of the cookie object.
String. Sets the value of the cookie object.
Cookie.
This method is applicable only for Response objects. The Cookie value will be included in the HTTP header that is sent to the client.
This sample adds a cookie to the cookie collection and returns the number of cookies in that collection.
<%
On Error Resume Next %>
<% ’Adds a new cookie to the collection
set New = response.cookies.add ("cookie1","users1")
if not (New is nothing) then
new.expires = now + 1
response.write "Added Cookie1"
else
response.write "Did not add Cookie1"
endif
Response.write %>
<% ’Returns the number of cookies in the collection
Set cnt = Response.cookies.count
Response.write ("The number of cookies in the collection
is: "&cnt) %>
Returns the specified Cookie object corresponding to the given key value.
object.Element(
Key As AnyType)
String/Integer. If the key value is a string it corresponds to the name of a cookie and if it is an Integer it represents the index of the cookie.
Cookie object.
Returns the name of the cookie object present in the specific collection.
object.GetName
None.
String.
To use this method, the cookie must be available in that collection.
See sample in Value property.
Retrieves the value of the cookie object in the specific cookies collection.
object.GetValue
None.
String.
To use this method, the cookie object must be available in the specific cookies collection.
Retrieves the Cookie object that corresponds to the Key.
object.Item(
Key As AnyType)
String/Integer. If the key value is a string it corresponds to the name of a cookie and if it is an Integer it represents the index of the cookie.
Cookie.
Retrieves the next Cookie object from the collection.
object.Next()
None.
Cookie.
Removes the specified Cookie object from the collection.
object.Remove(
Key As AnyType)
String/Integer. If the key value is a string it corresponds to the name of a cookie and if it is an Integer it represents the index of the cookie.
Boolean.
This method is applicable only for Response objects. The Cookie value will be included in the HTTP header that is sent to the client.
Resets the current object pointer to the beginning of the collection so the next call to Next method retrieves the first cookie in the collection.
object.Reset()
None.
None.