You are here

public function FileCookieJar::load in Auth0 Single Sign On 8.2

Load cookies from a JSON formatted file.

Old cookies are kept unless overwritten by newly loaded ones.

Parameters

string $filename Cookie file to load.:

Throws

\RuntimeException if the file cannot be loaded.

1 call to FileCookieJar::load()
FileCookieJar::__construct in vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php
Create a new FileCookieJar object

File

vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php, line 73

Class

FileCookieJar
Persists non-session cookies using a JSON formatted file

Namespace

GuzzleHttp\Cookie

Code

public function load($filename) {
  $json = file_get_contents($filename);
  if (false === $json) {
    throw new \RuntimeException("Unable to load file {$filename}");
  }
  elseif ($json === '') {
    return;
  }
  $data = \GuzzleHttp\json_decode($json, true);
  if (is_array($data)) {
    foreach (json_decode($json, true) as $cookie) {
      $this
        ->setCookie(new SetCookie($cookie));
    }
  }
  elseif (strlen($data)) {
    throw new \RuntimeException("Invalid cookie file: {$filename}");
  }
}