Class Requests_Cookie
Methods summary
public
|
#
__construct( string $name, string $value, array|Requests_Utility_CaseInsensitiveDictionary $attributes = array(), $flags = array(), $reference_time = null )
Create a new cookie object
Create a new cookie object
Parameters
- $name
- $value
- $attributes
- Associative array of attribute data
- $flags
- $reference_time
|
public
boolean
|
#
is_expired( )
Check if a cookie is expired.
Check if a cookie is expired.
Checks the age against $this->reference_time to determine if the cookie
is expired.
Returns
boolean True if expired, false if time is valid.
|
public
boolean
|
#
uri_matches( Requests_IRI $uri )
Check if a cookie is valid for a given URI
Check if a cookie is valid for a given URI
Parameters
Returns
boolean Whether the cookie is valid for the given URI
|
public
boolean
|
#
domain_matches( string $string )
Check if a cookie is valid for a given domain
Check if a cookie is valid for a given domain
Parameters
Returns
boolean Whether the cookie is valid for the given domain
|
public
boolean
|
#
path_matches( string $request_path )
Check if a cookie is valid for a given path
Check if a cookie is valid for a given path
From the path-match check in RFC 6265 section 5.1.4
Parameters
- $request_path
- Path to check
Returns
boolean Whether the cookie is valid for the given path
|
public
boolean
|
#
normalize( )
Normalize cookie and attributes
Normalize cookie and attributes
Returns
boolean Whether the cookie was successfully normalized
|
protected
mixed
|
#
normalize_attribute( string $name, string|boolean $value )
Parse an individual cookie attribute
Parse an individual cookie attribute
Handles parsing individual attributes from the cookie values.
Parameters
- $name
- Attribute name
- $value
- Attribute value (string value, or true if empty/flag)
Returns
mixed Value if available, or null if the attribute value is invalid (and should be skipped)
|
public
string
|
#
format_for_set_cookie( )
Format a cookie for a Set-Cookie header
Format a cookie for a Set-Cookie header
This is used when sending cookies to clients. This isn't really
applicable to client-side usage, but might be handy for debugging.
Returns
string Cookie formatted for Set-Cookie header
|
public
string
|
#
formatForSetCookie( )
Format a cookie for a Set-Cookie header
Format a cookie for a Set-Cookie header
Deprecated
Returns
string
Codecoverageignore
|
public
|
#
__toString( )
Get the cookie value
Attributes and other data can be accessed via methods.
|
public static
Requests_Cookie
|
#
parse( string $string, $name = '', $reference_time = null )
Parse a cookie string into a cookie object
Parse a cookie string into a cookie object
Based on Mozilla's parsing code in Firefox and related projects, which
is an intentional deviation from RFC 2109 and RFC 2616. RFC 6265
specifies some of this handling, but not in a thorough manner.
Parameters
- $string
- header value (from a Set-Cookie header)
- $name
- $reference_time
Returns
|
Properties summary
public
string
|
$name
|
|
public
string
|
$value
|
|
public
Requests_Utility_CaseInsensitiveDictionary|array
|
$attributes
Cookie attributes
Valid keys are (currently) path, domain, expires, max-age, secure and
httponly.
|
|
public
array
|
$flags
Cookie flags
Valid keys are (currently) creation, last-access, persistent and
host-only.
|
|
public
integer
|
$reference_time
Reference time for relative calculations
Reference time for relative calculations
This is used in place of time() when calculating Max-Age expiration and
checking time validity.
|
|