Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Zend_Http_Cookie Class Reference

Public Member Functions

 __construct ($name, $value, $domain, $expires=null, $path=null, $secure=false)
 Cookie object constructor.
 
 getName ()
 Get Cookie name.
 
 getValue ()
 Get cookie value.
 
 getDomain ()
 Get cookie domain.
 
 getPath ()
 Get the cookie path.
 
 getExpiryTime ()
 Get the expiry time of the cookie, or null if no expiry time is set.
 
 isSecure ()
 Check whether the cookie should only be sent over secure connections.
 
 isExpired ($now=null)
 Check whether the cookie has expired.
 
 isSessionCookie ()
 Check whether the cookie is a session cookie (has no expiry time set)
 
 match ($uri, $matchSessionCookies=true, $now=null)
 Checks whether the cookie should be sent or not in a specific scenario.
 
 __toString ()
 Get the cookie as a string, suitable for sending as a "Cookie" header in an HTTP request.
 

Static Public Member Functions

static fromString ($cookieStr, $refUri=null, $encodeValue=true)
 Generate a new Cookie object from a cookie string (for example the value of the Set-Cookie HTTP header)
 
static matchCookieDomain ($cookieDomain, $host)
 Check if a cookie's domain matches a host name.
 
static matchCookiePath ($cookiePath, $path)
 Check if a cookie's path matches a URL path.
 

Protected Attributes

 $name
 
 $value
 
 $expires
 
 $domain
 
 $path
 
 $secure
 
 $encodeValue
 

Constructor & Destructor Documentation

__construct (   $name,
  $value,
  $domain,
  $expires = null,
  $path = null,
  $secure = false 
)

Cookie object constructor.

Todo:
Add validation of each one of the parameters (legal domain, etc.)
Parameters
string$name
string$value
string$domain
int$expires
string$path
bool$secure

Member Function Documentation

__toString ( )

Get the cookie as a string, suitable for sending as a "Cookie" header in an HTTP request.

Returns
string
static fromString (   $cookieStr,
  $refUri = null,
  $encodeValue = true 
)
static

Generate a new Cookie object from a cookie string (for example the value of the Set-Cookie HTTP header)

Parameters
string$cookieStr
Zend_Uri_Http | string$refUriReference URI for default values (domain, path)
boolean$encodeValueWhether or not the cookie's value should be passed through urlencode/urldecode
Returns
Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.

The expiration is past Tue, 19 Jan 2038 03:14:07 UTC the maximum for 32-bit signed integer. Zend_Date can get around that limit.

See Also
Zend_Date
getDomain ( )

Get cookie domain.

Returns
string
getExpiryTime ( )

Get the expiry time of the cookie, or null if no expiry time is set.

Returns
int|null
getName ( )

Get Cookie name.

Returns
string
getPath ( )

Get the cookie path.

Returns
string
getValue ( )

Get cookie value.

Returns
string
isExpired (   $now = null)

Check whether the cookie has expired.

Always returns false if the cookie is a session cookie (has no expiry time)

Parameters
int$nowTimestamp to consider as "now"
Returns
boolean
isSecure ( )

Check whether the cookie should only be sent over secure connections.

Returns
boolean
isSessionCookie ( )

Check whether the cookie is a session cookie (has no expiry time set)

Returns
boolean
match (   $uri,
  $matchSessionCookies = true,
  $now = null 
)

Checks whether the cookie should be sent or not in a specific scenario.

Parameters
string | Zend_Uri_Http$uriURI to check against (secure, domain, path)
boolean$matchSessionCookiesWhether to send session cookies
int$nowOverride the current time when checking for expiry time
Returns
boolean
static matchCookieDomain (   $cookieDomain,
  $host 
)
static

Check if a cookie's domain matches a host name.

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters
string$cookieDomain
string$host
Returns
boolean
static matchCookiePath (   $cookiePath,
  $path 
)
static

Check if a cookie's path matches a URL path.

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters
string$cookiePath
string$path
Returns
boolean

Member Data Documentation

$domain
protected
$encodeValue
protected
$expires
protected
$name
protected
$path
protected
$secure
protected
$value
protected