CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • CookieCollection
  • FormData
  • Message
  • Request
  • Response

Interfaces

  • AdapterInterface

Class CookieCollection

Container class for cookies used in Http\Client.

Provides cookie jar like features for storing cookies between requests, as well as appending cookies to new requests.

Cake\Http\Cookie\CookieCollection implements IteratorAggregate, Countable
Extended by Cake\Http\Client\CookieCollection
Namespace: Cake\Http\Client
Deprecated: 3.5.0 Use Cake\Http\Cookie\CookieCollection instead.
Location: Http/Client/CookieCollection.php

Inherited Properties

  • cookies

Method Summary

  • __construct() public deprecated
    Constructor
  • convertCookieToArray() protected deprecated
    Convert the cookie into an array of its properties.
  • get() public deprecated
    Get stored cookies for a URL.
  • getAll() public deprecated
    Get all the stored cookies as arrays.
  • store() public deprecated
    Store the cookies from a response.

Method Detail

__construct() public deprecated ¶

__construct( array $cookies = [] )

Constructor

Parameters
array $cookies optional []
Array of cookie objects
Overrides
Cake\Http\Cookie\CookieCollection::__construct()

convertCookieToArray() protected deprecated ¶

convertCookieToArray( Cake\Http\Cookie\CookieInterface $cookie )

Convert the cookie into an array of its properties.

Primarily useful where backwards compatibility is needed.

Parameters
Cake\Http\Cookie\CookieInterface $cookie
Cookie object.
Returns
array

get() public deprecated ¶

get( string $url )

Get stored cookies for a URL.

Finds matching stored cookies and returns a simple array of name => value

Parameters
string $url
The URL to find cookies for.
Returns
array
Overrides
Cake\Http\Cookie\CookieCollection::get()

getAll() public deprecated ¶

getAll( )

Get all the stored cookies as arrays.

Returns
array

store() public deprecated ¶

store( Cake\Http\Client\Response $response , string $url )

Store the cookies from a response.

Store the cookies that haven't expired. If a cookie has been expired and is currently stored, it will be removed.

Parameters
Cake\Http\Client\Response $response
The response to read cookies from
string $url
The request URL used for default host/path values.

Methods inherited from Cake\Http\Cookie\CookieCollection

add() public ¶

add( Cake\Http\Cookie\CookieInterface $cookie )

Add a cookie and get an updated collection.

Cookies are stored by id. This means that there can be duplicate cookies if a cookie collection is used for cookies across multiple domains. This can impact how get(), has() and remove() behave.

Parameters
Cake\Http\Cookie\CookieInterface $cookie
Cookie instance to add.
Returns
Cake\Http\Cookie\CookieCollection

addFromResponse() public ¶

addFromResponse( Psr\Http\Message\ResponseInterface $response , Psr\Http\Message\RequestInterface $request )

Create a new collection that includes cookies from the response.

Parameters
Psr\Http\Message\ResponseInterface $response
Response to extract cookies from.
Psr\Http\Message\RequestInterface $request
Request to get cookie context from.
Returns
Cake\Http\Cookie\CookieCollection

addToRequest() public ¶

addToRequest( Psr\Http\Message\RequestInterface $request , array $extraCookies = [] )

Add cookies that match the path/domain/expiration to the request.

This allows CookieCollections to be used as a 'cookie jar' in an HTTP client situation. Cookies that match the request's domain + path that are not expired when this method is called will be applied to the request.

Parameters
Psr\Http\Message\RequestInterface $request
The request to update.
array $extraCookies optional []

Associative array of additional cookies to add into the request. This is useful when you have cookie data from outside the collection you want to send.

Returns
Psr\Http\Message\RequestInterface
An updated request.

checkCookies() protected ¶

checkCookies( array $cookies )

Checks if only valid cookie objects are in the array

Parameters
array $cookies
Array of cookie objects
Throws
InvalidArgumentException

count() public ¶

count( )

Get the number of cookies in the collection.

Returns
integer
Implementation of
Countable::count()

createFromHeader() public static ¶

createFromHeader( array $header )

Create a Cookie Collection from an array of Set-Cookie Headers

Parameters
array $header
The array of set-cookie header values.
Returns
Cake\Http\Cookie\CookieCollection

createFromServerRequest() public static ¶

createFromServerRequest( Psr\Http\Message\ServerRequestInterface $request )

Create a new collection from the cookies in a ServerRequest

Parameters
Psr\Http\Message\ServerRequestInterface $request
The request to extract cookie data from
Returns
Cake\Http\Cookie\CookieCollection

findMatchingCookies() protected ¶

findMatchingCookies( string $scheme , string $host , string $path )

Find cookies matching the scheme, host, and path

Parameters
string $scheme
The http scheme to match
string $host
The host to match.
string $path
The path to match
Returns
array
An array of cookie name/value pairs

getIterator() public ¶

getIterator( )

Gets the iterator

Returns
ArrayIterator
Implementation of
IteratorAggregate::getIterator()

has() public ¶

has( string $name )

Check if a cookie with the given name exists

Parameters
string $name
The cookie name to check.
Returns
boolean
True if the cookie exists, otherwise false.

parseSetCookieHeader() protected static ¶

parseSetCookieHeader( array $values )

Parse Set-Cookie headers into array

Parameters
array $values
List of Set-Cookie Header values.
Returns
Cake\Http\Cookie\Cookie[]
An array of cookie objects

remove() public ¶

remove( string $name )

Create a new collection with all cookies matching $name removed.

If the cookie is not in the collection, this method will do nothing.

Parameters
string $name
The name of the cookie to remove.
Returns
Cake\Http\Cookie\CookieCollection

removeExpiredCookies() protected ¶

removeExpiredCookies( string $host , string $path )

Remove expired cookies from the collection.

Parameters
string $host
The host to check for expired cookies on.
string $path
The path to check for expired cookies on.

setRequestDefaults() protected ¶

setRequestDefaults( array $cookies , string $host , string $path )

Apply path and host to the set of cookies if they are not set.

Parameters
array $cookies
An array of cookies to update.
string $host
The host to set.
string $path
The path to set.
Returns
array
An array of updated cookies.
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs