67 $clone = clone($this);
95 $clone = clone($this);
114 $clone = clone($this);
123 $clone = clone($this);
125 $clone->path =
$path;
132 $clone = clone($this);
141 $clone = clone($this);
150 $clone = clone($this);
159 $cookieStringParts = [
160 urlencode($this->name).
'='.urlencode($this->value),
170 return implode(
'; ', $cookieStringParts);
180 return static::create(
$name,
$value)->rememberForever();
185 return static::create(
$name)->expire();
188 public static function fromSetCookieString($string)
197 if (! is_null($cookieValue)) {
198 $setCookie = $setCookie->withValue($cookieValue);
201 while ($rawAttribute = array_shift($rawAttributes)) {
202 $rawAttributePair = explode(
'=', $rawAttribute, 2);
204 $attributeKey = $rawAttributePair[0];
205 $attributeValue = count($rawAttributePair) > 1 ? $rawAttributePair[1] : null;
207 $attributeKey = strtolower($attributeKey);
209 switch ($attributeKey) {
211 $setCookie = $setCookie->withExpires($attributeValue);
214 $setCookie = $setCookie->withMaxAge($attributeValue);
217 $setCookie = $setCookie->withDomain($attributeValue);
220 $setCookie = $setCookie->withPath($attributeValue);
223 $setCookie = $setCookie->withSecure(
true);
226 $setCookie = $setCookie->withHttpOnly(
true);
237 $cookieStringParts[] = sprintf(
"Domain=%s", $this->domain);
240 return $cookieStringParts;
246 $cookieStringParts[] = sprintf(
"Path=%s", $this->path);
249 return $cookieStringParts;
254 if ($this->expires) {
255 $cookieStringParts[] = sprintf(
"Expires=%s", gmdate(
'D, d M Y H:i:s T', $this->expires));
258 return $cookieStringParts;
264 $cookieStringParts[] = sprintf(
"Max-Age=%s", $this->maxAge);
267 return $cookieStringParts;
273 $cookieStringParts[] =
'Secure';
276 return $cookieStringParts;
281 if ($this->httpOnly) {
282 $cookieStringParts[] =
'HttpOnly';
285 return $cookieStringParts;
appendFormattedMaxAgePartIfSet(array $cookieStringParts)
__construct($name, $value=null)
appendFormattedHttpOnlyPartIfSet(array $cookieStringParts)
static create($name, $value=null)
static createRememberedForever($name, $value=null)
withHttpOnly($httpOnly=null)
appendFormattedDomainPartIfSet(array $cookieStringParts)
appendFormattedPathPartIfSet(array $cookieStringParts)
static splitOnAttributeDelimiter($string)
appendFormattedExpiresPartIfSet(array $cookieStringParts)
static createExpired($name)
resolveExpires($expires=null)
appendFormattedSecurePartIfSet(array $cookieStringParts)
Create styles array
The data for the language used.
static splitCookiePair($string)
withExpires($expires=null)