Debian Codegraph @

lib/3rdParty/composer/symfony/http-foundation/Session/SessionInterface.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;
13
14 use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
15
16 /**
17 * Interface for the session.
18 *
19 * @author Drak <[email protected]>
20 */
21 interface SessionInterface
22 {
23 /**
24 * Starts the session storage.
25 *
26 * @throws \RuntimeException if session fails to start
27 */
28 public function start(): bool;
29
30 /**
31 * Returns the session ID.
32 */
33 public function getId(): string;
34
35 /**
36 * Sets the session ID.
37 */
38 public function setId(string $id): void;
39
40 /**
41 * Returns the session name.
42 */
43 public function getName(): string;
44
45 /**
46 * Sets the session name.
47 */
48 public function setName(string $name): void;
49
50 /**
51 * Invalidates the current session.
52 *
53 * Clears all session attributes and flashes and regenerates the
54 * session and deletes the old session from persistence.
55 *
56 * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value
57 * will leave the system settings unchanged, 0 sets the cookie
58 * to expire with browser session. Time is in seconds, and is
59 * not a Unix timestamp.
60 */
61 public function invalidate(?int $lifetime = null): bool;
62
63 /**
64 * Migrates the current session to a new session id while maintaining all
65 * session attributes.
66 *
67 * @param bool $destroy Whether to delete the old session or leave it to garbage collection
68 * @param int|null $lifetime Sets the cookie lifetime for the session cookie. A null value
69 * will leave the system settings unchanged, 0 sets the cookie
70 * to expire with browser session. Time is in seconds, and is
71 * not a Unix timestamp.
72 */
73 public function migrate(bool $destroy = false, ?int $lifetime = null): bool;
74
75 /**
76 * Force the session to be saved and closed.
77 *
78 * This method is generally not required for real sessions as
79 * the session will be automatically saved at the end of
80 * code execution.
81 */
82 public function save(): void;
83
84 /**
85 * Checks if an attribute is defined.
86 */
87 public function has(string $name): bool;
88
89 /**
90 * Returns an attribute.
91 */
92 public function get(string $name, mixed $default = null): mixed;
93
94 /**
95 * Sets an attribute.
96 */
97 public function set(string $name, mixed $value): void;
98
99 /**
100 * Returns attributes.
101 */
102 public function all(): array;
103
104 /**
105 * Sets attributes.
106 */
107 public function replace(array $attributes): void;
108
109 /**
110 * Removes an attribute.
111 *
112 * @return mixed The removed value or null when it does not exist
113 */
114 public function remove(string $name): mixed;
115
116 /**
117 * Clears all attributes.
118 */
119 public function clear(): void;
120
121 /**
122 * Checks if the session was started.
123 */
124 public function isStarted(): bool;
125
126 /**
127 * Registers a SessionBagInterface with the session.
128 */
129 public function registerBag(SessionBagInterface $bag): void;
130
131 /**
132 * Gets a bag instance by name.
133 */
134 public function getBag(string $name): SessionBagInterface;
135
136 /**
137 * Gets session meta.
138 */
139 public function getMetadataBag(): MetadataBag;
140 }