ePages 6.11.0 - DE_EPAGES/WebInterface/API/Cookie.pm

Package DE_EPAGES::WebInterface::API::Cookie

@EXPORT_OK
SetCookie
GetCookies

Functions

GetCookies
SetCookie

GetCookies

Extracts all cookies from the HTTP Request object. The current implementation will not work if any value is quoted and/or contains a ';' character.

Syntax
$hCookies = GetCookies( $HttpRequest );
Input
$HttpRequest (HTTP::Request object)
HTTP request
Return
$hCockies (hash ref)
all cookies as name => value pairs

SetCookie

Adds a Set-Cookie HTTP header to the response according to RFC 2109. Note that you should always send addition Cache-Control headers with a response that sets cookies. To prevent caching by HTTP/1.0 proxy servers, also add a Expires: old-date header. The Cache-Control directive will override the Expires: old-date for HTTP/1.1 proxies.

Syntax
SetCookie( $HttpResponse, $Name, $Value, $hAttributes );
Example
SetCookie( $HttpResponse, 'SessionID', '12345', { 'Max-Age' => 31536000 } );
Input
$HttpResponse (HTTP::Response object)
HTTP response
$Name
$Value
$hAttributes (ref.hash)
optional attributes
  • Comment - informs the user about the intent of the cookie
  • Domain - domain name, for example '.epages.de'
  • Max-Age - session lifetime in seconds. A value of "0"
    terminates a current session by deleting the cookie.
    If not specified, the cookie lives until the user agent
    is closed (aka. session cookie)
  • Path - specifies the subset of URLs to which this cookie applies,
    for example "/epages/MyStore.storefront"
  • secure - specifies that the cookie requires a secure connection (SSL)
  • HttpOnly - specifies that the cookie is not visible for JavaScript
  • Version - version of the cookie specification, default: 1
.
Note that the "Expires" attribute that was proposed by Netscape is
obsolete with RFC 2109.