Debian Codegraph @

lib/3rdParty/composer/symfony/http-foundation/Session/Storage/SessionStorageInterface.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\HttpFoundation\Session\Storage;
13
14 use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
15
16 /**
17 * StorageInterface.
18 *
19 * @author Fabien Potencier <[email protected]>
20 * @author Drak <[email protected]>
21 */
22 interface SessionStorageInterface
23 {
24 /**
25 * Starts the session.
26 *
27 * @throws \RuntimeException if something goes wrong starting the session
28 */
29 public function start(): bool;
30
31 /**
32 * Checks if the session is started.
33 */
34 public function isStarted(): bool;
35
36 /**
37 * Returns the session ID.
38 */
39 public function getId(): string;
40
41 /**
42 * Sets the session ID.
43 */
44 public function setId(string $id): void;
45
46 /**
47 * Returns the session name.
48 */
49 public function getName(): string;
50
51 /**
52 * Sets the session name.
53 */
54 public function setName(string $name): void;
55
56 /**
57 * Regenerates id that represents this storage.
58 *
59 * This method must invoke session_regenerate_id($destroy) unless
60 * this interface is used for a storage object designed for unit
61 * or functional testing where a real PHP session would interfere
62 * with testing.
63 *
64 * Note regenerate+destroy should not clear the session data in memory
65 * only delete the session data from persistent storage.
66 *
67 * Care: When regenerating the session ID no locking is involved in PHP's
68 * session design. See https://bugs.php.net/61470 for a discussion.
69 * So you must make sure the regenerated session is saved BEFORE sending the
70 * headers with the new ID. Symfony's HttpKernel offers a listener for this.
71 * See Symfony\Component\HttpKernel\EventListener\SaveSessionListener.
72 * Otherwise session data could get lost again for concurrent requests with the
73 * new ID. One result could be that you get logged out after just logging in.
74 *
75 * @param bool $destroy Destroy session when regenerating?
76 * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value
77 * will leave the system settings unchanged, 0 sets the cookie
78 * to expire with browser session. Time is in seconds, and is
79 * not a Unix timestamp.
80 *
81 * @throws \RuntimeException If an error occurs while regenerating this storage
82 */
83 public function regenerate(bool $destroy = false, ?int $lifetime = null): bool;
84
85 /**
86 * Force the session to be saved and closed.
87 *
88 * This method must invoke session_write_close() unless this interface is
89 * used for a storage object design for unit or functional testing where
90 * a real PHP session would interfere with testing, in which case
91 * it should actually persist the session data if required.
92 *
93 * @throws \RuntimeException if the session is saved without being started, or if the session
94 * is already closed
95 */
96 public function save(): void;
97
98 /**
99 * Clear all session data in memory.
100 */
101 public function clear(): void;
102
103 /**
104 * Gets a SessionBagInterface by name.
105 *
106 * @throws \InvalidArgumentException If the bag does not exist
107 */
108 public function getBag(string $name): SessionBagInterface;
109
110 /**
111 * Registers a SessionBagInterface for use.
112 */
113 public function registerBag(SessionBagInterface $bag): void;
114
115 public function getMetadataBag(): MetadataBag;
116 }