Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
GuzzleHttp\Cookie\FileCookieJar Class Reference
Inheritance diagram for GuzzleHttp\Cookie\FileCookieJar:
GuzzleHttp\Cookie\CookieJar GuzzleHttp\Cookie\CookieJarInterface

Public Member Functions

 __construct (string $cookieFile, bool $storeSessionCookies=false)
 Create a new FileCookieJar object.
 
 __destruct ()
 Saves the file when shutting down.
 
 clear (?string $domain=null, ?string $path=null, ?string $name=null)
 @inheritDoc
 
 clearSessionCookies ()
 @inheritDoc
 
 count ()
 
 extractCookies (RequestInterface $request, ResponseInterface $response)
 Extract cookies from an HTTP response and store them in the CookieJar.
 
 getCookieByName (string $name)
 Finds and returns the cookie based on the name.
 
 getIterator ()
 
 load (string $filename)
 Load cookies from a JSON formatted file.
 
 save (string $filename)
 Saves the cookies to a file.
 
 setCookie (SetCookie $cookie)
 @inheritDoc
 
 toArray ()
 @inheritDoc
 
 withCookieHeader (RequestInterface $request)
 Create a request with added cookie headers.
 

Static Public Member Functions

static fromArray (array $cookies, string $domain)
 Create a new Cookie jar from an associative array and domain.
 
static shouldPersist (SetCookie $cookie, bool $allowSessionCookies=false)
 Evaluate if this cookie should be persisted to storage that survives between requests.
 

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Cookie\FileCookieJar::__construct ( string $cookieFile,
bool $storeSessionCookies = false )

Create a new FileCookieJar object.

Parameters
string$cookieFileFile to store the cookie data
bool$storeSessionCookiesSet to true to store session cookies in the cookie jar.
Exceptions
RuntimeExceptionif the file cannot be found or created

Member Function Documentation

◆ clear()

GuzzleHttp\Cookie\CookieJar::clear ( ?string $domain = null,
?string $path = null,
?string $name = null )
inherited

@inheritDoc

Implements GuzzleHttp\Cookie\CookieJarInterface.

◆ clearSessionCookies()

GuzzleHttp\Cookie\CookieJar::clearSessionCookies ( )
inherited

@inheritDoc

Implements GuzzleHttp\Cookie\CookieJarInterface.

◆ extractCookies()

GuzzleHttp\Cookie\CookieJar::extractCookies ( RequestInterface $request,
ResponseInterface $response )
inherited

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

Parameters
RequestInterface$requestRequest that was sent
ResponseInterface$responseResponse that was received

Implements GuzzleHttp\Cookie\CookieJarInterface.

◆ fromArray()

static GuzzleHttp\Cookie\CookieJar::fromArray ( array $cookies,
string $domain )
staticinherited

Create a new Cookie jar from an associative array and domain.

Parameters
array$cookiesCookies to create the jar from
string$domainDomain to set the cookies to

◆ getCookieByName()

GuzzleHttp\Cookie\CookieJar::getCookieByName ( string $name)
inherited

Finds and returns the cookie based on the name.

Parameters
string$namecookie name to search for
Return values
SetCookie|nullcookie that was found or null if not found

◆ getIterator()

GuzzleHttp\Cookie\CookieJar::getIterator ( )
inherited
Return values
ArrayIterator<int,SetCookie>

◆ load()

GuzzleHttp\Cookie\FileCookieJar::load ( string $filename)

Load cookies from a JSON formatted file.

Old cookies are kept unless overwritten by newly loaded ones.

Parameters
string$filenameCookie file to load.
Exceptions
RuntimeExceptionif the file cannot be loaded.

◆ save()

GuzzleHttp\Cookie\FileCookieJar::save ( string $filename)

Saves the cookies to a file.

Parameters
string$filenameFile to save
Exceptions
RuntimeExceptionif the file cannot be found or created

◆ setCookie()

GuzzleHttp\Cookie\CookieJar::setCookie ( SetCookie $cookie)
inherited

@inheritDoc

Implements GuzzleHttp\Cookie\CookieJarInterface.

◆ shouldPersist()

static GuzzleHttp\Cookie\CookieJar::shouldPersist ( SetCookie $cookie,
bool $allowSessionCookies = false )
staticinherited

Evaluate if this cookie should be persisted to storage that survives between requests.

Parameters
SetCookie$cookieBeing evaluated.
bool$allowSessionCookiesIf we should persist session cookies

◆ toArray()

GuzzleHttp\Cookie\CookieJar::toArray ( )
inherited

@inheritDoc

Implements GuzzleHttp\Cookie\CookieJarInterface.

◆ withCookieHeader()

GuzzleHttp\Cookie\CookieJar::withCookieHeader ( RequestInterface $request)
inherited

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
RequestInterface$requestRequest object to modify.
Return values
RequestInterfacereturns the modified request.

Implements GuzzleHttp\Cookie\CookieJarInterface.


The documentation for this class was generated from the following file: