Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 317 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CookieJar:: (14 methods):
  __construct()
  fromArray()
  shouldPersist()
  getCookieByName()
  toArray()
  clear()
  clearSessionCookies()
  setCookie()
  count()
  getIterator()
  extractCookies()
  getCookiePathFromRequest()
  withCookieHeader()
  removeCookieIfEmpty()


Class: CookieJar  - X-Ref

Cookie jar that stores cookies as an array

__construct(bool $strictMode = false, array $cookieArray = [])   X-Ref

param: bool  $strictMode  Set to true to throw exceptions when invalid
param: array $cookieArray Array of SetCookie objects or a hash of

fromArray(array $cookies, string $domain)   X-Ref
Create a new Cookie jar from an associative array and domain.

param: array  $cookies Cookies to create the jar from
param: string $domain  Domain to set the cookies to

shouldPersist(SetCookie $cookie, bool $allowSessionCookies = false)   X-Ref
Evaluate if this cookie should be persisted to storage
that survives between requests.

param: SetCookie $cookie              Being evaluated.
param: bool      $allowSessionCookies If we should persist session cookies

getCookieByName(string $name)   X-Ref
Finds and returns the cookie based on the name

param: string $name cookie name to search for
return: SetCookie|null cookie that was found or null if not found

toArray()   X-Ref


clear(?string $domain = null, ?string $path = null, ?string $name = null)   X-Ref


clearSessionCookies()   X-Ref
No description

setCookie(SetCookie $cookie)   X-Ref
No description

count()   X-Ref
No description

getIterator()   X-Ref

return: \ArrayIterator<int, SetCookie>

extractCookies(RequestInterface $request, ResponseInterface $response)   X-Ref
No description

getCookiePathFromRequest(RequestInterface $request)   X-Ref
Computes cookie path following RFC 6265 section 5.1.4


withCookieHeader(RequestInterface $request)   X-Ref
No description

removeCookieIfEmpty(SetCookie $cookie)   X-Ref
If a cookie already exists and the server asks to set it again with a
null value, the cookie must be deleted.