\GuzzleHttp\CookieCookieJarInterface

Stores HTTP cookies.

It extracts cookies from HTTP requests, and returns them in HTTP responses. CookieJarInterface instances automatically expire contained cookies when necessary. Subclasses are also responsible for storing and retrieving cookies from a file, database, etc.

Summary

Methods
Constants
withCookieHeader()
extractCookies()
setCookie()
clear()
clearSessionCookies()
toArray()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

withCookieHeader()

withCookieHeader(\Psr\Http\Message\RequestInterface  $request) : \Psr\Http\Message\RequestInterface

Create a request with added cookie headers.

If no matching cookies are found in the cookie jar, then no Cookie header is added to the request and the same request is returned.

Parameters

\Psr\Http\Message\RequestInterface $request

Request object to modify.

Returns

\Psr\Http\Message\RequestInterface

returns the modified request.

extractCookies()

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

Extract cookies from an HTTP response and store them in the CookieJar.

Parameters

\Psr\Http\Message\RequestInterface $request

Request that was sent

\Psr\Http\Message\ResponseInterface $response

Response that was received

setCookie()

setCookie(\GuzzleHttp\Cookie\SetCookie  $cookie) : boolean

Sets a cookie in the cookie jar.

Parameters

\GuzzleHttp\Cookie\SetCookie $cookie

Cookie to set.

Returns

boolean —

Returns true on success or false on failure

clear()

clear(string  $domain = null, string  $path = null, string  $name = null) : \GuzzleHttp\Cookie\CookieJarInterface

Remove cookies currently held in the cookie jar.

Invoking this method without arguments will empty the whole cookie jar. If given a $domain argument only cookies belonging to that domain will be removed. If given a $domain and $path argument, cookies belonging to the specified path within that domain are removed. If given all three arguments, then the cookie with the specified name, path and domain is removed.

Parameters

string $domain

Clears cookies matching a domain

string $path

Clears cookies matching a domain and path

string $name

Clears cookies matching a domain, path, and name

Returns

\GuzzleHttp\Cookie\CookieJarInterface

clearSessionCookies()

clearSessionCookies() 

Discard all sessions cookies.

Removes cookies that don't have an expire field or a have a discard field set to true. To be called when the user agent shuts down according to RFC 2965.

toArray()

toArray() : array

Converts the cookie jar to an array.

Returns

array