Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
SessionCookieJar.php
01 <?php
02 namespace GuzzleHttp\Cookie;
03
04 use GuzzleHttp\Utils;
05
06 /**
07 * Persists cookies in the client session
08 */
09 class SessionCookieJar extends CookieJar
10 {
11 /** @var string session key */
12 private $sessionKey;
13
14 /**
15 * Create a new SessionCookieJar object
16 *
17 * @param string $sessionKey Session key name to store the cookie data in session
18 */
19 public function __construct($sessionKey)
20 {
21 $this->sessionKey = $sessionKey;
22 $this->load();
23 }
24
25 /**
26 * Saves cookies to session when shutting down
27 */
28 public function __destruct()
29 {
30 $this->save();
31 }
32
33 /**
34 * Save cookies to the client session
35 */
36 public function save()
37 {
38 $json = [];
39 foreach ($this as $cookie) {
40 if ($cookie->getExpires() && !$cookie->getDiscard()) {
41 $json[] = $cookie->toArray();
42 }
43 }
44
45 $_SESSION[$this->sessionKey] = json_encode($json);
46 }
47
48 /**
49 * Load the contents of the client session into the data array
50 */
51 protected function load()
52 {
53 $cookieJar = isset($_SESSION[$this->sessionKey])
54 ? $_SESSION[$this->sessionKey]
55 : null;
56
57 $data = Utils::jsonDecode($cookieJar, true);
58 if (is_array($data)) {
59 foreach ($data as $cookie) {
60 $this->setCookie(new SetCookie($cookie));
61 }
62 } elseif (strlen($data)) {
63 throw new \RuntimeException("Invalid cookie data");
64 }
65 }
66 }
67