Definition at line 47 of file Cookie.php.
◆ __construct()
__construct |
( |
|
$name, |
|
|
|
$value, |
|
|
|
$domain, |
|
|
|
$expires = null , |
|
|
|
$path = null , |
|
|
|
$secure = false |
|
) |
| |
Cookie object constructor
- Todo:
- Add validation of each one of the parameters (legal domain, etc.)
- Parameters
-
string | $name | |
string | $value | |
string | $domain | |
int | $expires | |
string | $path | |
bool | $secure | |
Definition at line 110 of file Cookie.php.
112 if (preg_match(
"/[=,; \t\r\n\013\014]/",
$name)) {
113 #require_once 'Zend/Http/Exception.php'; 114 throw new Zend_Http_Exception(
"Cookie name cannot contain these characters: =,; \\t\\r\\n\\013\\014 ({$name})");
118 #require_once 'Zend/Http/Exception.php'; 122 if (! $this->domain = (
string)
$domain) {
123 #require_once 'Zend/Http/Exception.php';
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
◆ __toString()
Get the cookie as a string, suitable for sending as a "Cookie" header in an HTTP request
- Returns
- string
Definition at line 266 of file Cookie.php.
268 if ($this->encodeValue) {
269 return $this->
name .
'=' . urlencode($this->
value) .
';';
271 return $this->
name .
'=' . $this->
value .
';';
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
◆ fromString()
static fromString |
( |
|
$cookieStr, |
|
|
|
$refUri = null , |
|
|
|
$encodeValue = true |
|
) |
| |
|
static |
Generate a new Cookie object from a cookie string (for example the value of the Set-Cookie HTTP header)
- Parameters
-
string | $cookieStr | |
Zend_Uri_Http | string | $refUri | Reference URI for default values (domain, path) |
boolean | $encodeValue | Whether or not the cookie's value should be passed through urlencode/urldecode |
- Returns
- Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.
The expiration is past Tue, 19 Jan 2038 03:14:07 UTC the maximum for 32-bit signed integer. Zend_Date can get around that limit.
- See also
- Zend_Date
Definition at line 284 of file Cookie.php.
287 if (is_string($refUri)) {
288 $refUri = Zend_Uri_Http::factory($refUri);
297 $parts = explode(
';', $cookieStr);
300 if (strpos($parts[0],
'=') ===
false)
return false;
303 list(
$name,
$value) = explode(
'=', trim(array_shift($parts)), 2);
310 if ($refUri instanceof Zend_Uri_Http) {
312 $path = $refUri->getPath();
317 foreach ($parts as $part) {
319 if (strtolower($part) ==
'secure') {
324 $keyValue = explode(
'=', $part, 2);
325 if (count($keyValue) == 2) {
326 list($k, $v) = $keyValue;
327 switch (strtolower($k)) {
329 if((
$expires = strtotime($v)) ===
false) {
337 #require_once 'Zend/Date.php'; 340 $expires = $expireDate->getTimestamp();
◆ getDomain()
Get cookie domain
- Returns
- string
Definition at line 158 of file Cookie.php.
◆ getExpiryTime()
Get the expiry time of the cookie, or null if no expiry time is set
- Returns
- int|null
Definition at line 178 of file Cookie.php.
◆ getName()
Get Cookie name
- Returns
- string
Definition at line 138 of file Cookie.php.
◆ getPath()
Get the cookie path
- Returns
- string
Definition at line 168 of file Cookie.php.
◆ getValue()
Get cookie value
- Returns
- string
Definition at line 148 of file Cookie.php.
◆ isExpired()
Check whether the cookie has expired
Always returns false if the cookie is a session cookie (has no expiry time)
- Parameters
-
int | $now | Timestamp to consider as "now" |
- Returns
- boolean
Definition at line 201 of file Cookie.php.
203 if ($now ===
null) $now =
time();
204 if (is_int($this->expires) && $this->expires < $now) {
◆ isSecure()
Check whether the cookie should only be sent over secure connections
- Returns
- boolean
Definition at line 188 of file Cookie.php.
◆ isSessionCookie()
Check whether the cookie is a session cookie (has no expiry time set)
- Returns
- boolean
Definition at line 216 of file Cookie.php.
218 return ($this->expires ===
null);
◆ match()
match |
( |
|
$uri, |
|
|
|
$matchSessionCookies = true , |
|
|
|
$now = null |
|
) |
| |
Checks whether the cookie should be sent or not in a specific scenario
- Parameters
-
string | Zend_Uri_Http | $uri | URI to check against (secure, domain, path) |
boolean | $matchSessionCookies | Whether to send session cookies |
int | $now | Override the current time when checking for expiry time |
- Returns
- boolean
Definition at line 229 of file Cookie.php.
231 if (is_string ($uri)) {
232 $uri = Zend_Uri_Http::factory($uri);
236 if (! ($uri->valid() && ($uri->getScheme() ==
'http' || $uri->getScheme() ==
'https'))) {
237 #require_once 'Zend/Http/Exception.php'; 242 if ($this->secure && $uri->getScheme() !=
'https')
return false;
243 if ($this->
isExpired($now))
return false;
247 if (! self::matchCookieDomain($this->
getDomain(), $uri->getHost())) {
252 if (! self::matchCookiePath($this->
getPath(), $uri->getPath())) {
◆ matchCookieDomain()
static matchCookieDomain |
( |
|
$cookieDomain, |
|
|
|
$host |
|
) |
| |
|
static |
Check if a cookie's domain matches a host name.
Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching
- Parameters
-
string | $cookieDomain | |
string | $host | |
- Returns
- boolean
Definition at line 377 of file Cookie.php.
379 if (! $cookieDomain) {
380 #require_once 'Zend/Http/Exception.php'; 385 #require_once 'Zend/Http/Exception.php'; 389 $cookieDomain = strtolower($cookieDomain);
390 $host = strtolower($host);
392 if ($cookieDomain[0] ==
'.') {
393 $cookieDomain = substr($cookieDomain, 1);
397 return ($cookieDomain == $host ||
398 preg_match(
'/\.' . preg_quote($cookieDomain) .
'$/', $host));
◆ matchCookiePath()
static matchCookiePath |
( |
|
$cookiePath, |
|
|
|
$path |
|
) |
| |
|
static |
Check if a cookie's path matches a URL path
Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching
- Parameters
-
string | $cookiePath | |
string | $path | |
- Returns
- boolean
Definition at line 410 of file Cookie.php.
413 #require_once 'Zend/Http/Exception.php'; 418 #require_once 'Zend/Http/Exception.php'; 422 return (strpos(
$path, $cookiePath) === 0);
◆ $domain
◆ $encodeValue
◆ $expires
◆ $name
◆ $path
◆ $secure
◆ $value
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Http/Cookie.php