Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Licensed to Jasig under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Jasig licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

Author: Adam Franco <afranco@middlebury.edu>
License: http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
File Size: 384 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CAS_CookieJar:: (9 methods):
  __construct()
  storeCookies()
  getCookies()
  parseCookieHeaders()
  parseCookieHeader()
  storeCookie()
  discardCookie()
  expireCookies()
  cookieMatchesTarget()


Class: CAS_CookieJar  - X-Ref

This class provides access to service cookies and handles parsing of response
headers to pull out cookie values.

__construct(array &$storageArray)   X-Ref
Create a new cookie jar by passing it a reference to an array in which it
should store cookies.

param: array &$storageArray Array to store cookies
return: void

storeCookies($request_url, $response_headers)   X-Ref
Store cookies for a web service request.
Cookie storage is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

param: string $request_url      The URL that generated the response headers.
param: array  $response_headers An array of the HTTP response header strings.
return: void

getCookies($request_url)   X-Ref
Retrieve cookies applicable for a web service request.
Cookie applicability is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

param: string $request_url The url that the cookies will be for.
return: array An array containing cookies. E.g. array('name' => 'val');

parseCookieHeaders( $header, $defaultDomain )   X-Ref
Parse Cookies without PECL
From the comments in http://php.net/manual/en/function.http-parse-cookie.php

param: array  $header        array of header lines.
param: string $defaultDomain The domain to use if none is specified in
return: array of cookies

parseCookieHeader($line, $defaultDomain)   X-Ref
Parse a single cookie header line.

Based on RFC2965 http://www.ietf.org/rfc/rfc2965.txt

param: string $line          The header line.
param: string $defaultDomain The domain to use if none is specified in
return: array

storeCookie($cookie)   X-Ref
Add, update, or remove a cookie.

param: array $cookie A cookie array as created by parseCookieHeaders()
return: void

discardCookie($cookie)   X-Ref
Discard an existing cookie

param: array $cookie An cookie
return: void

expireCookies()   X-Ref
Go through our stored cookies and remove any that are expired.

return: void

cookieMatchesTarget($cookie, $target)   X-Ref
Answer true if cookie is applicable to a target.

param: array $cookie An array of cookie attributes.
param: array|false $target An array of URL attributes as generated by parse_url().
return: bool