Reading Cookies in Classic ASP

The Form collection is used to retrieve the values of form elements from a form that uses the POST method.

Note: If you want to post large amounts of data (beyond 100 kb) the Request.Form cannot be used.

Arguments:

Request.Cookies(name)[(key)|.attribute]
  • name (Required)
    The name of the cookie
  • attribute (Optional)
    Specifies information about the cookie. Can be one of the following parameters:
    • Domain - Write-only. The cookie is sent only to requests to this domain
    • Expires - Write-only. The date when the cookie expires. If no date is specified, the cookie will expire when the session ends
    • HasKeys - Read-only. Specifies whether the cookie has keys (This is the only attribute that can be used with the Request.Cookies command)
    • Path - Write-only. If set, the cookie is sent only to requests to this path. If not set, the application path is used
    • Secure - Write-only. Indicates if the cookie is secure
  • key (Optional)
    Specifies the key to where the value is assigned

Examples:

The "Request.Cookies" command is used to get a cookie value.

In the example below, we retrieve the value of the cookie "firstname" and display it on a page:

<%
	fname=Request.Cookies("firstname")
	response.write("Firstname=" & fname)
%>

Tutorial:

You can find out more about using Request.Cookies by reading our Cookies Tutorial.

Written By: S2H, 9th July 2006

Bookmark

Advertisement