phpCAS version 1.3.6

Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CAS_CookieJar Class Reference

## Public Member Functions
| __construct (array &$storageArray)
| storeCookies ($request_url, $response_headers)
| getCookies ($request_url)

## Protected Member Functions
| parseCookieHeaders ( $header, $defaultDomain)
| parseCookieHeader ($line, $defaultDomain)
| storeCookie ($cookie)
| discardCookie ($cookie)
| expireCookies ()
| cookieMatchesTarget ($cookie, $target)

## Private Attributes
| $_cookies

## Detailed Description

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

Definition at line 41 of file CookieJar.php.

## Constructor & Destructor Documentation

## ◆ __construct()

CAS_CookieJar::__construct | ( | array & | $storageArray | ) |

Create a new cookie jar by passing it a reference to an array in which it should store cookies.

Parameters

  array | &$storageArray | Array to store cookies

Returns
  void

Definition at line 54 of file CookieJar.php.

## Member Function Documentation

## ◆ cookieMatchesTarget()

CAS_CookieJar::cookieMatchesTarget | ( |  | $cookie,
|  |  | $target
| ) |  |
| protected

Answer true if cookie is applicable to a target.

Parameters

  array | $cookie | An array of cookie attributes.
  array | $target | An array of URL attributes as generated by parse_url().

Returns
  bool

private

Definition at line 317 of file CookieJar.php.

Referenced by getCookies(), and storeCookies().

## ◆ discardCookie()

CAS_CookieJar::discardCookie | ( |  | $cookie | ) |
| protected

Discard an existing cookie

Parameters

  array | $cookie | An cookie

Returns
  void

protected

Definition at line 272 of file CookieJar.php.

Referenced by storeCookie().

## ◆ expireCookies()

CAS_CookieJar::expireCookies | ( |  | ) |
| protected

Go through our stored cookies and remove any that are expired.

Returns
  void

protected

Definition at line 298 of file CookieJar.php.

Referenced by getCookies().

## ◆ getCookies()

CAS_CookieJar::getCookies | ( |  | $request_url | ) |

Retrieve cookies applicable for a web service request. Cookie applicability is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

Parameters

  string | $request_url | The url that the cookies will be for.

Returns
  array An array containing cookies. E.g. array('name' => 'val');

private

Definition at line 102 of file CookieJar.php.

References cookieMatchesTarget(), and expireCookies().

## ◆ parseCookieHeader()

CAS_CookieJar::parseCookieHeader | ( |  | $line,
|  |  | $defaultDomain
| ) |  |
| protected

Parse a single cookie header line.

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

Parameters

  string | $line | The header line.
  string | $defaultDomain | The domain to use if none is specified in the cookie.

Returns
  array

Definition at line 161 of file CookieJar.php.

References phpCAS\trace().

Referenced by parseCookieHeaders().

## ◆ parseCookieHeaders()

CAS_CookieJar::parseCookieHeaders | ( |  | $header,
|  |  | $defaultDomain
| ) |  |
| protected

Parse Cookies without PECL From the comments in http://php.net/manual/en/function.http-parse-cookie.php

Parameters

  array | $header | array of header lines.
  string | $defaultDomain | The domain to use if none is specified in the cookie.

Returns
  array of cookies

Definition at line 136 of file CookieJar.php.

References parseCookieHeader(), phpCAS\traceBegin(), and phpCAS\traceEnd().

Referenced by storeCookies().

## ◆ storeCookie()

CAS_CookieJar::storeCookie | ( |  | $cookie | ) |
| protected

Add, update, or remove a cookie.

Parameters

  array | $cookie | A cookie array as created by parseCookieHeaders()

Returns
  void

protected

Definition at line 255 of file CookieJar.php.

References discardCookie().

Referenced by storeCookies().

## ◆ storeCookies()

CAS_CookieJar::storeCookies | ( |  | $request_url,
|  |  | $response_headers
| ) |  |

Store cookies for a web service request. Cookie storage is based on RFC 2965: http://www.ietf.org/rfc/rfc2965.txt

Parameters

  string | $request_url | The URL that generated the response headers.
  array | $response_headers | An array of the HTTP response header strings.

Returns
  void

private

Definition at line 70 of file CookieJar.php.

References cookieMatchesTarget(), parseCookieHeaders(), storeCookie(), and phpCAS\trace().

## Member Data Documentation

## ◆ $_cookies

CAS_CookieJar::$_cookies
| private

Definition at line 44 of file CookieJar.php.