API Documentation

Zend/Http/Cookie.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Http  
Subpackage
Cookie  
Version
$Id: Cookie.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Http_Cookie

Package: Zend\Http

Zend_Http_Cookie is a class describing an HTTP cookie and all it's parameters.

Zend_Http_Cookie is a class describing an HTTP cookie and all it's parameters. The class also enables validating whether the cookie should be sent to the server in a specified scenario according to the request URI, the expiry time and whether session cookies should be used or not. Generally speaking cookies should be contained in a Cookiejar object, or instantiated manually and added to an HTTP request.

See http://wp.netscape.com/newsref/std/cookie_spec.html for some specs.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

Propertyprotectedstring  $domain= ''

Cookie domain

Details
Type
string
Propertyprotectedboolean  $encodeValue= ''

Whether the cookie value has been encoded/decoded

Details
Type
boolean
Propertyprotectedint  $expires= ''

Cookie expiry date

Details
Type
int
Propertyprotectedstring  $name= ''

Cookie name

Details
Type
string
Propertyprotectedstring  $path= ''

Cookie path

Details
Type
string
Propertyprotectedboolean  $secure= ''

Whether the cookie is secure or not

Details
Type
boolean
Propertyprotectedstring  $value= ''

Cookie value

Details
Type
string

Methods

methodpublic__construct( string $name, string $value, string $domain, int $expires = null, string $path = null, bool $secure = false ) : void

Cookie object constructor

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

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

Returns
Type Description
string
methodpublicfromString( string $cookieStr, \Zend_Uri_Http|string $refUri = null, boolean $encodeValue = true ) : \Zend_Http_Cookie
static

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

Parameters
Name Type Description
$cookieStr string
$refUri \Zend_Uri_Http|string

Reference URI for default values (domain, path)

$encodeValue boolean

Whether or not the cookie's value should be passed through urlencode/urldecode

Returns
Type Description
\Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure.
methodpublicgetDomain( ) : string

Get cookie domain

Returns
Type Description
string
methodpublicgetExpiryTime( ) : int|null

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

Returns
Type Description
int|null
methodpublicgetName( ) : string

Get Cookie name

Returns
Type Description
string
methodpublicgetPath( ) : string

Get the cookie path

Returns
Type Description
string
methodpublicgetValue( ) : string

Get cookie value

Returns
Type Description
string
methodpublicisExpired( int $now = null ) : boolean

Check whether the cookie has expired

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

Parameters
Name Type Description
$now int

Timestamp to consider as "now"

Returns
Type Description
boolean
methodpublicisSecure( ) : boolean

Check whether the cookie should only be sent over secure connections

Returns
Type Description
boolean
methodpublicisSessionCookie( ) : boolean

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

Returns
Type Description
boolean
methodpublicmatch( string|\Zend_Uri_Http $uri, boolean $matchSessionCookies = true, int $now = null ) : boolean

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

Parameters
Name Type Description
$uri string|\Zend_Uri_Http

URI to check against (secure, domain, path)

$matchSessionCookies boolean

Whether to send session cookies

$now int

Override the current time when checking for expiry time

Returns
Type Description
boolean
methodpublicmatchCookieDomain( string $cookieDomain, string $host ) : boolean
static

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

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters
Name Type Description
$cookieDomain string
$host string
Returns
Type Description
boolean
methodpublicmatchCookiePath( string $cookiePath, string $path ) : boolean
static

Check if a cookie's path matches a URL path

Used by Zend_Http_Cookie and Zend_Http_CookieJar for cookie matching

Parameters
Name Type Description
$cookiePath string
$path string
Returns
Type Description
boolean
Documentation was generated by DocBlox 0.15.1.