MediaWiki master
Cookie Class Reference

Public Member Functions

 __construct ( $name, $value, $attr)
 
 serializeToHttpRequest ( $path, $domain)
 Serialize the cookie jar into a format useful for HTTP Request headers.
 
 set ( $value, $attr)
 Sets a cookie.
 

Static Public Member Functions

static validateCookieDomain ( $domain, $originDomain=null)
 Return the true if the cookie is valid is valid.
 

Protected Member Functions

 canServeDomain ( $domain)
 
 canServePath ( $path)
 
 isUnExpired ()
 

Protected Attributes

string null $domain
 
int false $expires
 
bool $isSessionKey = true
 
string $name
 
string null $path
 
string $value
 

Detailed Description

Definition at line 24 of file Cookie.php.

Constructor & Destructor Documentation

◆ __construct()

Cookie::__construct ( $name,
$value,
$attr )

Definition at line 42 of file Cookie.php.

References $name, and $value.

Member Function Documentation

◆ canServeDomain()

Cookie::canServeDomain ( $domain)
protected
Parameters
string$domain
Returns
bool

Definition at line 171 of file Cookie.php.

References $domain.

Referenced by serializeToHttpRequest().

◆ canServePath()

Cookie::canServePath ( $path)
protected
Parameters
string$path
Returns
bool

Definition at line 194 of file Cookie.php.

References $path.

Referenced by serializeToHttpRequest().

◆ isUnExpired()

Cookie::isUnExpired ( )
protected
Returns
bool

Definition at line 201 of file Cookie.php.

Referenced by serializeToHttpRequest().

◆ serializeToHttpRequest()

Cookie::serializeToHttpRequest ( $path,
$domain )

Serialize the cookie jar into a format useful for HTTP Request headers.

Parameters
string$pathThe path that will be used. Required.
string$domainThe domain that will be used. Required.
Returns
string

Definition at line 155 of file Cookie.php.

References $domain, $path, $value, canServeDomain(), canServePath(), and isUnExpired().

◆ set()

Cookie::set ( $value,
$attr )

Sets a cookie.

Used before a request to set up any individual cookies. Used internally after a request to parse the Set-Cookie headers.

Parameters
string$valueThe value of the cookie
array$attrPossible key/values: expires A date string path The path this cookie is used on domain Domain this cookie is used on

Definition at line 58 of file Cookie.php.

References $value.

◆ validateCookieDomain()

static Cookie::validateCookieDomain ( $domain,
$originDomain = null )
static

Return the true if the cookie is valid is valid.

Otherwise, false. The uses a method similar to IE cookie security described here: http://kuza55.blogspot.com/2008/02/understanding-cookie-security.html A better method might be to use a list like http://publicsuffix.org/

Todo

fixme fails to detect 3-letter top-level domains

fixme fails to detect 2-letter top-level domains for single-domain use (probably not a big problem in practice, but there are test cases)

Parameters
string$domainThe domain to validate
string | null$originDomain(optional) the domain the cookie originates from
Returns
bool

Definition at line 93 of file Cookie.php.

References $domain.

Referenced by CookieJar\parseCookieResponseHeader().

Member Data Documentation

◆ $domain

string null Cookie::$domain
protected

Definition at line 34 of file Cookie.php.

Referenced by canServeDomain(), serializeToHttpRequest(), and validateCookieDomain().

◆ $expires

int false Cookie::$expires
protected

Definition at line 30 of file Cookie.php.

◆ $isSessionKey

bool Cookie::$isSessionKey = true
protected

Definition at line 36 of file Cookie.php.

◆ $name

string Cookie::$name
protected

Definition at line 26 of file Cookie.php.

Referenced by __construct().

◆ $path

string null Cookie::$path
protected

Definition at line 32 of file Cookie.php.

Referenced by canServePath(), and serializeToHttpRequest().

◆ $value

string Cookie::$value
protected

Definition at line 28 of file Cookie.php.

Referenced by __construct(), serializeToHttpRequest(), and set().


The documentation for this class was generated from the following file: