Definition at line 34 of file CookieJar.php.
HTTP_Request2_CookieJar::__construct |
( |
|
$serializeSessionCookies = false , |
|
|
|
$usePublicSuffixList = true |
|
) |
| |
Class constructor, sets various options
- Parameters
-
Definition at line 79 of file CookieJar.php.
Adds cookies set in HTTP response to the jar
- Parameters
-
Definition at line 226 of file CookieJar.php.
HTTP_Request2_CookieJar::checkAndUpdateFields |
( |
array |
$cookie, |
|
|
Net_URL2 |
$setter = null |
|
) |
| |
|
protected |
Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields
The checks are as follows:
- cookie array should contain 'name' and 'value' fields;
- name and value should not contain disallowed symbols;
- 'expires' should be either empty parseable by DateTime;
- 'domain' and 'path' should be either not empty or an URL where cookie was set should be provided.
- if $setter is provided, then document at that URL should be allowed to set a cookie for that 'domain'. If $setter is not provided, then no domain checks will be made.
'expires' field will be converted to ISO8601 format from COOKIE format, 'domain' and 'path' will be set from setter URL if empty.
- Parameters
-
- Returns
- array Updated cookie array
- Exceptions
-
Definition at line 122 of file CookieJar.php.
static HTTP_Request2_CookieJar::checkDomainsList |
( |
array |
$domainParts, |
|
|
|
$listNode |
|
) |
| |
|
staticprotected |
HTTP_Request2_CookieJar::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.
- Parameters
-
string | $requestHost | request host |
string | $cookieDomain | cookie domain |
- Returns
- bool match success
Definition at line 398 of file CookieJar.php.
HTTP_Request2_CookieJar::getAll |
( |
| ) |
|
Returns all cookies stored in a jar
- Returns
- array
Definition at line 286 of file CookieJar.php.
HTTP_Request2_CookieJar::getMatching |
( |
Net_URL2 |
$url, |
|
|
|
$asString = false |
|
) |
| |
Returns all cookies matching a given request URL
The following checks are made:
- cookie domain should match request host
- cookie path should be a prefix for request path
- 'secure' cookies will only be sent for HTTPS requests
- Parameters
-
Net_URL2 | $url | Request url |
bool | $asString | Whether to return cookies as string for "Cookie: " header |
- Returns
- array|string Matching cookies
Definition at line 246 of file CookieJar.php.
static HTTP_Request2_CookieJar::getRegisteredDomain |
( |
|
$domain | ) |
|
|
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.
- Parameters
-
- Returns
- string|bool registered domain, will return false if $domain is either invalid or a TLD itself
Definition at line 431 of file CookieJar.php.
HTTP_Request2_CookieJar::now |
( |
| ) |
|
|
protected |
Returns current time formatted in ISO-8601 at UTC timezone
- Returns
- string
Definition at line 91 of file CookieJar.php.
HTTP_Request2_CookieJar::serialize |
( |
| ) |
|
Returns string representation of object
- Returns
- string
- See Also
- Serializable::serialize()
Definition at line 342 of file CookieJar.php.
HTTP_Request2_CookieJar::serializeSessionCookies |
( |
|
$serialize | ) |
|
Sets whether session cookies should be serialized when serializing the jar
- Parameters
-
boolean | $serialize | serialize? |
Definition at line 304 of file CookieJar.php.
HTTP_Request2_CookieJar::store |
( |
array |
$cookie, |
|
|
Net_URL2 |
$setter = null |
|
) |
| |
Stores a cookie in the jar
- Parameters
-
- Exceptions
-
Definition at line 199 of file CookieJar.php.
HTTP_Request2_CookieJar::unserialize |
( |
|
$serialized | ) |
|
Constructs the object from serialized string
- Parameters
-
string | $serialized | string representation |
- See Also
- Serializable::unserialize()
Definition at line 366 of file CookieJar.php.
HTTP_Request2_CookieJar::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.
- Parameters
-
boolean | $useList | use the list? |
http://publicsuffix.org/learn/
Definition at line 330 of file CookieJar.php.
HTTP_Request2_CookieJar::$cookies = array() |
|
protected |
HTTP_Request2_CookieJar::$psl = array() |
|
staticprotected |
HTTP_Request2_CookieJar::$serializeSession = false |
|
protected |
HTTP_Request2_CookieJar::$useList = true |
|
protected |
The documentation for this class was generated from the following file: