Copied!

Set-Cookie object

CloneableInstantiable
Methods
public __construct(array $data = [])
 
public __toString() : string
public static fromString(string $cookie) : self
 

Create a new SetCookie object from a string.

public getDiscard()
 

Get whether or not this is a session cookie.

public getDomain()
public getExpires()
 

The UNIX timestamp when the cookie Expires.

public getHttpOnly()
 

Get whether or not this is an HTTP only cookie.

public getMaxAge()
 

Maximum lifetime of the cookie in seconds.

public getName()
 

Get the cookie name.

public getPath()
public getSecure()
 

Get whether or not this is a secure cookie.

public getValue()
 

Get the cookie value.

public isExpired() : bool
 

Check if the cookie is expired.

public matchesDomain(string $domain) : bool
 

Check if the cookie matches a domain value.

public matchesPath(string $requestPath) : bool
 

Check if the cookie matches a path value.

A request-path path-matches a given cookie-path if at least one of
the following conditions holds:

  • The cookie-path and the request-path are identical.
  • The cookie-path is a prefix of the request-path, and the last
    character of the cookie-path is %x2F ("/").
  • The cookie-path is a prefix of the request-path, and the first
    character of the request-path that is not included in the cookie-
    path is a %x2F ("/") character.
public setDiscard( $discard) : void
 

Set whether or not this is a session cookie.

public setDomain( $domain) : void
 

Set the domain of the cookie.

public setExpires( $timestamp) : void
 

Set the unix timestamp for which the cookie will expire.

public setHttpOnly( $httpOnly) : void
 

Set whether or not this is an HTTP only cookie.

public setMaxAge( $maxAge) : void
 

Set the max-age of the cookie.

public setName( $name) : void
 

Set the cookie name.

public setPath( $path) : void
 

Set the path of the cookie.

public setSecure( $secure) : void
 

Set whether or not the cookie is secure.

public setValue( $value) : void
 

Set the cookie value.

public toArray() : array
public validate()
 

Check if the cookie is valid according to RFC 6265.

Properties
private $data
private static $defaults = ['Name' => NULL, 'Value' => NULL, 'Domain' => NULL, 'Path' => '/', 'Max-Age' => NULL, 'Expires' => NULL, 'Secure' => false, 'Discard' => false, 'HttpOnly' => false]
Properties
private static $defaults = ['Name' => NULL, 'Value' => NULL, 'Domain' => NULL, 'Path' => '/', 'Max-Age' => NULL, 'Expires' => NULL, 'Secure' => false, 'Discard' => false, 'HttpOnly' => false]
Methods
public static fromString(string $cookie) : self
 

Create a new SetCookie object from a string.

© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration