![]() |
TYPO3
7.6
|
Public Member Functions | |
__construct ($serializeSessionCookies=false, $usePublicSuffixList=true) | |
store (array $cookie, Net_URL2 $setter=null) | |
addCookiesFromResponse (HTTP_Request2_Response $response, Net_URL2 $setter) | |
getMatching (Net_URL2 $url, $asString=false) | |
getAll () | |
serializeSessionCookies ($serialize) | |
usePublicSuffixList ($useList) | |
serialize () | |
unserialize ($serialized) | |
domainMatch ($requestHost, $cookieDomain) | |
Static Public Member Functions | |
static | getRegisteredDomain ($domain) |
Protected Member Functions | |
now () | |
checkAndUpdateFields (array $cookie, Net_URL2 $setter=null) | |
Static Protected Member Functions | |
static | checkDomainsList (array $domainParts, $listNode) |
Protected Attributes | |
$cookies = array() | |
$serializeSession = false | |
$useList = true | |
Static Protected Attributes | |
static | $psl = array() |
Definition at line 34 of file CookieJar.php.
__construct | ( | $serializeSessionCookies = false , |
|
$usePublicSuffixList = true |
|||
) |
Class constructor, sets various options
bool | $serializeSessionCookies | Controls serializing session cookies, see serializeSessionCookies() |
bool | $usePublicSuffixList | Controls using Public Suffix List, see usePublicSuffixList() |
Definition at line 79 of file CookieJar.php.
References serializeSessionCookies(), and usePublicSuffixList().
addCookiesFromResponse | ( | HTTP_Request2_Response | $response, |
Net_URL2 | $setter | ||
) |
Adds cookies set in HTTP response to the jar
HTTP_Request2_Response | $response | HTTP response message |
Net_URL2 | $setter | original request URL, needed for setting default domain/path |
Definition at line 226 of file CookieJar.php.
References HTTP_Request2_Response\getCookies(), and store().
|
protected |
Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields
The checks are as follows:
'expires' field will be converted to ISO8601 format from COOKIE format, 'domain' and 'path' will be set from setter URL if empty.
array | $cookie | cookie data, as returned by HTTP_Request2_Response::getCookies() |
Net_URL2 | $setter | URL of the document that sent Set-Cookie header |
Definition at line 122 of file CookieJar.php.
References domainMatch(), HTTP_Request2_Exception\INVALID_ARGUMENT, HTTP_Request2_Exception\MISSING_VALUE, and HTTP_Request2\REGEXP_INVALID_COOKIE.
Referenced by store().
|
staticprotected |
Recursive helper method for getRegisteredDomain()
array | $domainParts | remaining domain parts |
mixed | $listNode | node in HTTP_Request2_CookieJar::$psl to check |
Definition at line 471 of file CookieJar.php.
References elseif.
domainMatch | ( | $requestHost, | |
$cookieDomain | |||
) |
Checks whether a cookie domain matches a request host.
The method is used by store() to check for whether a document at given URL can set a cookie with a given domain attribute and by getMatching() to find cookies matching the request URL.
string | $requestHost | request host |
string | $cookieDomain | cookie domain |
Definition at line 398 of file CookieJar.php.
Referenced by checkAndUpdateFields(), and getMatching().
getAll | ( | ) |
Returns all cookies stored in a jar
Definition at line 286 of file CookieJar.php.
References $cookies.
Referenced by serialize().
getMatching | ( | Net_URL2 | $url, |
$asString = false |
|||
) |
Returns all cookies matching a given request URL
The following checks are made:
Net_URL2 | $url | Request url |
bool | $asString | Whether to return cookies as string for "Cookie: " header |
Definition at line 246 of file CookieJar.php.
References $cookies, domainMatch(), Net_URL2\getHost(), Net_URL2\getPath(), and Net_URL2\getScheme().
|
static |
Removes subdomains to get the registered domain (the first after top-level)
The method will check Public Suffix List to find out where top-level domain ends and registered domain starts. It will remove domain parts to the left of registered one.
string | $domain | domain name |
Definition at line 431 of file CookieJar.php.
|
protected |
Returns current time formatted in ISO-8601 at UTC timezone
Definition at line 91 of file CookieJar.php.
Referenced by store(), and unserialize().
serialize | ( | ) |
Returns string representation of object
Definition at line 342 of file CookieJar.php.
serializeSessionCookies | ( | $serialize | ) |
Sets whether session cookies should be serialized when serializing the jar
boolean | $serialize | serialize? |
Definition at line 304 of file CookieJar.php.
Referenced by __construct(), and unserialize().
store | ( | array | $cookie, |
Net_URL2 | $setter = null |
||
) |
Stores a cookie in the jar
array | $cookie | cookie data, as returned by HTTP_Request2_Response::getCookies() |
Net_URL2 | $setter | URL of the document that sent Set-Cookie header |
HTTP_Request2_Exception |
Definition at line 199 of file CookieJar.php.
References checkAndUpdateFields(), elseif, and now().
Referenced by addCookiesFromResponse().
unserialize | ( | $serialized | ) |
Constructs the object from serialized string
string | $serialized | string representation |
Definition at line 366 of file CookieJar.php.
References now(), serializeSessionCookies(), and usePublicSuffixList().
usePublicSuffixList | ( | $useList | ) |
Sets whether Public Suffix List should be used for restricting cookie-setting
Without PSL domainMatch() will only prevent setting cookies for top-level domains like '.com' or '.org'. However, it will not prevent setting a cookie for '.co.uk' even though only third-level registrations are possible in .uk domain.
With the List it is possible to find the highest level at which a domain may be registered for a particular top-level domain and consequently prevent cookies set for '.co.uk' or '.msk.ru'. The same list is used by Firefox, Chrome and Opera browsers to restrict cookie setting.
Note that PSL is licensed differently to HTTP_Request2 package (refer to the license information in public-suffix-list.php), so you can disable its use if this is an issue for you.
boolean | $useList | use the list? |
http://publicsuffix.org/learn/
Definition at line 330 of file CookieJar.php.
References $useList.
Referenced by __construct(), and unserialize().
|
protected |
Definition at line 50 of file CookieJar.php.
Referenced by getAll(), getMatching(), and serialize().
|
staticprotected |
Definition at line 69 of file CookieJar.php.
|
protected |
Definition at line 56 of file CookieJar.php.
|
protected |
Definition at line 62 of file CookieJar.php.
Referenced by usePublicSuffixList().