PHP 클래스 yii\web\CookieCollection

For more details and usage information on CookieCollection, see the guide article on handling cookies.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Object, implements IteratorAggregate, implements ArrayAccess, implements Countable
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$readOnly whether this collection is read only.

공개 메소드들

메소드 설명
__construct ( array $cookies = [], array $config = [] ) Constructor.
add ( Cookie $cookie ) Adds a cookie to the collection.
count ( ) : integer Returns the number of cookies in the collection.
fromArray ( array $array ) Populates the cookie collection from an array.
get ( string $name ) : Cookie Returns the cookie with the specified name.
getCount ( ) : integer Returns the number of cookies in the collection.
getIterator ( ) : ArrayIterator Returns an iterator for traversing the cookies in the collection.
getValue ( string $name, mixed $defaultValue = null ) : mixed Returns the value of the named cookie.
has ( string $name ) : boolean Returns whether there is a cookie with the specified name.
offsetExists ( string $name ) : boolean Returns whether there is a cookie with the specified name.
offsetGet ( string $name ) : Cookie Returns the cookie with the specified name.
offsetSet ( string $name, Cookie $cookie ) Adds the cookie to the collection.
offsetUnset ( string $name ) Removes the named cookie.
remove ( Cookie | string $cookie, boolean $removeFromBrowser = true ) Removes a cookie.
removeAll ( ) Removes all cookies.
toArray ( ) : array Returns the collection as a PHP array.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $cookies = [], array $config = [] )
$cookies array the cookies that this collection initially contains. This should be an array of name-value pairs.
$config array name-value pairs that will be used to initialize the object properties

add() 공개 메소드

If there is already a cookie with the same name in the collection, it will be removed first.
public add ( Cookie $cookie )
$cookie Cookie the cookie to be added

count() 공개 메소드

This method is required by the SPL Countable interface. It will be implicitly called when you use count($collection).
public count ( ) : integer
리턴 integer the number of cookies in the collection.

fromArray() 공개 메소드

Populates the cookie collection from an array.
부터: 2.0.3
public fromArray ( array $array )
$array array the cookies to populate from

get() 공개 메소드

Returns the cookie with the specified name.
또한 보기: getValue()
public get ( string $name ) : Cookie
$name string the cookie name
리턴 Cookie the cookie with the specified name. Null if the named cookie does not exist.

getCount() 공개 메소드

Returns the number of cookies in the collection.
public getCount ( ) : integer
리턴 integer the number of cookies in the collection.

getIterator() 공개 메소드

This method is required by the SPL interface [[\IteratorAggregate]]. It will be implicitly called when you use foreach to traverse the collection.
public getIterator ( ) : ArrayIterator
리턴 ArrayIterator an iterator for traversing the cookies in the collection.

getValue() 공개 메소드

Returns the value of the named cookie.
또한 보기: get()
public getValue ( string $name, mixed $defaultValue = null ) : mixed
$name string the cookie name
$defaultValue mixed the value that should be returned when the named cookie does not exist.
리턴 mixed the value of the named cookie.

has() 공개 메소드

Note that if a cookie is marked for deletion from browser, this method will return false.
또한 보기: remove()
public has ( string $name ) : boolean
$name string the cookie name
리턴 boolean whether the named cookie exists

offsetExists() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like isset($collection[$name]).
public offsetExists ( string $name ) : boolean
$name string the cookie name
리턴 boolean whether the named cookie exists

offsetGet() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like $cookie = $collection[$name];. This is equivalent to CookieCollection::get.
public offsetGet ( string $name ) : Cookie
$name string the cookie name
리턴 Cookie the cookie with the specified name, null if the named cookie does not exist.

offsetSet() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like $collection[$name] = $cookie;. This is equivalent to CookieCollection::add.
public offsetSet ( string $name, Cookie $cookie )
$name string the cookie name
$cookie Cookie the cookie to be added

offsetUnset() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like unset($collection[$name]). This is equivalent to CookieCollection::remove.
public offsetUnset ( string $name )
$name string the cookie name

remove() 공개 메소드

If $removeFromBrowser is true, the cookie will be removed from the browser. In this case, a cookie with outdated expiry will be added to the collection.
public remove ( Cookie | string $cookie, boolean $removeFromBrowser = true )
$cookie Cookie | string the cookie object or the name of the cookie to be removed.
$removeFromBrowser boolean whether to remove the cookie from browser

removeAll() 공개 메소드

Removes all cookies.
public removeAll ( )

toArray() 공개 메소드

Returns the collection as a PHP array.
public toArray ( ) : array
리턴 array the array representation of the collection. The array keys are cookie names, and the array values are the corresponding cookie objects.

프로퍼티 상세

$readOnly 공개적으로 프로퍼티

whether this collection is read only.
public $readOnly