|
| __construct ($name=null, $value=null, $expires=null, $path=null, $domain=null, $secure=false, $httponly=false, $maxAge=null, $version=null) |
|
| getFieldName () |
|
| getFieldValue () |
|
| setName ($name) |
|
| getName () |
|
| setValue ($value) |
|
| getValue () |
|
| setVersion ($version) |
|
| getVersion () |
|
| setMaxAge ($maxAge) |
|
| getMaxAge () |
|
| setExpires ($expires) |
|
| getExpires ($inSeconds=false) |
|
| setDomain ($domain) |
|
| getDomain () |
|
| setPath ($path) |
|
| getPath () |
|
| setSecure ($secure) |
|
| isSecure () |
|
| setHttponly ($httponly) |
|
| isHttponly () |
|
| isExpired ($now=null) |
|
| isSessionCookie () |
|
| isValidForRequest ($requestDomain, $path, $isSecure=false) |
|
| toString () |
|
| __toString () |
|
| toStringMultipleHeaders (array $headers) |
|
Definition at line 52 of file SetCookie.php.
◆ __construct()
__construct |
( |
|
$name = null , |
|
|
|
$value = null , |
|
|
|
$expires = null , |
|
|
|
$path = null , |
|
|
|
$domain = null , |
|
|
|
$secure = false , |
|
|
|
$httponly = false , |
|
|
|
$maxAge = null , |
|
|
|
$version = null |
|
) |
| |
Cookie object constructor
- Todo:
- Add validation of each one of the parameters (legal domain, etc.)
- Parameters
-
string | $name | |
string | $value | |
int | $expires | |
string | $path | |
string | $domain | |
bool | $secure | |
bool | $httponly | |
string | $maxAge | |
int | $version | |
- Returns
- SetCookie
Definition at line 189 of file SetCookie.php.
191 $this->type =
'Cookie';
◆ __toString()
◆ fromString()
static fromString |
( |
|
$headerLine, |
|
|
|
$bypassHeaderFieldName = false |
|
) |
| |
|
static |
Generate a new Cookie object from a cookie string (for example the value of the Set-Cookie HTTP header)
- Exceptions
-
- Parameters
-
| $headerLine | |
bool | $bypassHeaderFieldName | |
- Returns
- array|SetCookie
Definition at line 126 of file SetCookie.php.
128 list(
$name,
$value) = explode(
': ', $headerLine, 2);
131 if (strtolower(
$name) !==
'set-cookie') {
135 $multipleHeaders = preg_split(
'#(?<!Sun|Mon|Tue|Wed|Thu|Fri|Sat),\s*#',
$value);
137 foreach ($multipleHeaders as $headerLine) {
138 $header =
new self();
139 $keyValuePairs = preg_split(
'#;\s*#', $headerLine);
140 foreach ($keyValuePairs as $keyValue) {
141 if (strpos($keyValue,
'=')) {
142 list($headerKey, $headerValue) = preg_split(
'#=\s*#', $keyValue, 2);
144 $headerKey = $keyValue;
149 if ($header->getName() === NULL) {
150 $header->setName($headerKey);
151 $header->setValue($headerValue);
156 switch (str_replace(array(
'-',
'_'),
'', strtolower($headerKey))) {
157 case 'expires' : $header->setExpires($headerValue);
break;
158 case 'domain' : $header->setDomain($headerValue);
break;
159 case 'path' : $header->setPath($headerValue);
break;
160 case 'secure' : $header->setSecure(
true);
break;
161 case 'httponly': $header->setHttponly(
true);
break;
162 case 'version' : $header->setVersion((
int) $headerValue);
break;
163 case 'maxage' : $header->setMaxAge((
int) $headerValue);
break;
168 $headers[] = $header;
170 return count($headers) == 1 ? array_pop($headers) : $headers;
◆ getDomain()
◆ getExpires()
getExpires |
( |
|
$inSeconds = false | ) |
|
- Returns
- int
Definition at line 398 of file SetCookie.php.
400 if ($this->expires ==
null) {
406 return gmdate(
'D, d-M-Y H:i:s', $this->expires) .
' GMT';
◆ getFieldName()
◆ getFieldValue()
- Exceptions
-
- Returns
- string
Definition at line 242 of file SetCookie.php.
249 if (strpos(
$value,
'"')!==
false) {
250 $value =
'"'.urlencode(str_replace(
'"',
'',
$value)).
'"';
258 $fieldValue .=
'; Version=' .
$version;
263 $fieldValue .=
'; Max-Age=' .
$maxAge;
268 $fieldValue .=
'; Expires=' .
$expires;
273 $fieldValue .=
'; Domain=' .
$domain;
278 $fieldValue .=
'; Path=' .
$path;
282 $fieldValue .=
'; Secure';
286 $fieldValue .=
'; HttpOnly';
◆ getMaxAge()
◆ getName()
◆ getPath()
◆ getValue()
◆ getVersion()
◆ 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 487 of file SetCookie.php.
493 if (is_int($this->expires) && $this->expires < $now) {
◆ isHttponly()
◆ isSecure()
◆ isSessionCookie()
Check whether the cookie is a session cookie (has no expiry time set)
- Returns
- boolean
Definition at line 505 of file SetCookie.php.
507 return ($this->expires ===
null);
◆ isValidForRequest()
isValidForRequest |
( |
|
$requestDomain, |
|
|
|
$path, |
|
|
|
$isSecure = false |
|
) |
| |
◆ setDomain()
◆ setExpires()
- Parameters
-
- Returns
- SetCookie
Definition at line 382 of file SetCookie.php.
elseif(isset( $params[ 'redirect_parent']))
◆ setHttponly()
◆ setMaxAge()
◆ setName()
- Parameters
-
- Returns
- SetCookie
Definition at line 296 of file SetCookie.php.
298 if (preg_match(
"/[=,; \t\r\n\013\014]/",
$name)) {
◆ setPath()
◆ setSecure()
◆ setValue()
- Parameters
-
Definition at line 317 of file SetCookie.php.
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
◆ setVersion()
◆ toString()
◆ toStringMultipleHeaders()
toStringMultipleHeaders |
( |
array |
$headers | ) |
|
Definition at line 538 of file SetCookie.php.
542 foreach ($headers as $header) {
545 'The SetCookie multiple header implementation can only accept an array of SetCookie headers' 548 $headerLine .=
', ' . $header->getFieldValue();
◆ $domain
◆ $expires
◆ $httponly
◆ $maxAge
◆ $name
◆ $path
◆ $secure
◆ $value
◆ $version
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Http/Header/SetCookie.php