CookieCollection

Type
Class
Namespace
Craft
Inherits
Craft\CookieCollection » CCookieCollection » CMap » CComponent
Implements
ArrayAccess, Countable, IteratorAggregate
Since
2.2

CookieCollection implements a collection class to store cookies. You normally access it via {@link HttpRequest::getCookies()}.

Since CookieCollection ultimately extends from {@link CMap}, it can be used like an associative array as follows:

$cookies[$name] = new HttpCookie($name, $value); // sends a cookie
$value = $cookies[$name]->value; // reads a cookie value
unset($cookies[$name]);  // removes a cookie

See also http://craftcms.com

View source

Public Methods

MethodDescription
__call()Calls the named method which is not a class method.
__construct()Constructor.
__get()Returns a property value, an event handler list or a behavior based on its name.
__isset()Checks if a property value is null.
__set()Sets value of a component property.
__unset()Sets a component property to be null.
add()Adds an item into the map.
asa()Returns the named behavior object.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
attachEventHandler()Attaches an event handler to an event.
canGetProperty()Determines whether a property can be read.
canSetProperty()Determines whether a property can be set.
clear()Removes all items in the map.
contains()
copyFrom()Copies iterable data into the map.
count()Returns the number of items in the map.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
detachEventHandler()Detaches an existing event handler.
disableBehavior()Disables an attached behavior.
disableBehaviors()Disables all behaviors attached to this component.
enableBehavior()Enables an attached behavior.
enableBehaviors()Enables all behaviors attached to this component.
evaluateExpression()Evaluates a PHP expression or callback under the context of this component.
getCount()Returns the number of items in the map.
getEventHandlers()Returns the list of attached event handlers for an event.
getIterator()Returns an iterator for traversing the items in the list.
getKeys()
getReadOnly()
getRequest()
hasEvent()Determines whether an event is defined.
hasEventHandler()Checks whether the named event has attached handlers.
hasProperty()Determines whether a property is defined.
itemAt()Returns the item with the specified key.
mergeArray()Merges two or more arrays into one recursively.
mergeWith()Merges iterable data into the map.
offsetExists()Returns whether there is an element at the specified offset.
offsetGet()Returns the element at the specified offset.
offsetSet()Sets the element at the specified offset.
offsetUnset()Unsets the element at the specified offset.
raiseEvent()Raises an event.
remove()Removes an item from the map by its key.
toArray()

Protected Methods

MethodDescription
addCookie()Sends a cookie.
getCookies()Returns a array of validated {@link HttpCookie} objects pulled from $_COOKIES.
removeCookie()Deletes a cookie.
setReadOnly()

getCookies()

Returns a array of validated {@link HttpCookie} objects pulled from $_COOKIES. Since Craft uses it's own {@link HttpCookie} class, we're overriding this to prevent is from getting duplicate identity cookies in the case someone has 'defaultCookieDomain' set to something custom.

View source

Returns

array – The array of validated cookies

Signature

protected array getCookies ( )