blob: 1bf025a096c8ae6a83b2844215cf51126c8a0b30 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Illuminate\Contracts\Session;
4
5interface Session
6{
7 /**
8 * Get the name of the session.
9 *
10 * @return string
11 */
12 public function getName();
13
14 /**
15 * Set the name of the session.
16 *
17 * @param string $name
18 * @return void
19 */
20 public function setName($name);
21
22 /**
23 * Get the current session ID.
24 *
25 * @return string
26 */
27 public function getId();
28
29 /**
30 * Set the session ID.
31 *
32 * @param string $id
33 * @return void
34 */
35 public function setId($id);
36
37 /**
38 * Start the session, reading the data from a handler.
39 *
40 * @return bool
41 */
42 public function start();
43
44 /**
45 * Save the session data to storage.
46 *
47 * @return void
48 */
49 public function save();
50
51 /**
52 * Get all of the session data.
53 *
54 * @return array
55 */
56 public function all();
57
58 /**
59 * Checks if a key exists.
60 *
61 * @param string|array $key
62 * @return bool
63 */
64 public function exists($key);
65
66 /**
67 * Checks if a key is present and not null.
68 *
69 * @param string|array $key
70 * @return bool
71 */
72 public function has($key);
73
74 /**
75 * Get an item from the session.
76 *
77 * @param string $key
78 * @param mixed $default
79 * @return mixed
80 */
81 public function get($key, $default = null);
82
83 /**
84 * Get the value of a given key and then forget it.
85 *
86 * @param string $key
87 * @param mixed $default
88 * @return mixed
89 */
90 public function pull($key, $default = null);
91
92 /**
93 * Put a key / value pair or array of key / value pairs in the session.
94 *
95 * @param string|array $key
96 * @param mixed $value
97 * @return void
98 */
99 public function put($key, $value = null);
100
101 /**
102 * Get the CSRF token value.
103 *
104 * @return string
105 */
106 public function token();
107
108 /**
109 * Regenerate the CSRF token value.
110 *
111 * @return void
112 */
113 public function regenerateToken();
114
115 /**
116 * Remove an item from the session, returning its value.
117 *
118 * @param string $key
119 * @return mixed
120 */
121 public function remove($key);
122
123 /**
124 * Remove one or many items from the session.
125 *
126 * @param string|array $keys
127 * @return void
128 */
129 public function forget($keys);
130
131 /**
132 * Remove all of the items from the session.
133 *
134 * @return void
135 */
136 public function flush();
137
138 /**
139 * Flush the session data and regenerate the ID.
140 *
141 * @return bool
142 */
143 public function invalidate();
144
145 /**
146 * Generate a new session identifier.
147 *
148 * @param bool $destroy
149 * @return bool
150 */
151 public function regenerate($destroy = false);
152
153 /**
154 * Generate a new session ID for the session.
155 *
156 * @param bool $destroy
157 * @return bool
158 */
159 public function migrate($destroy = false);
160
161 /**
162 * Determine if the session has been started.
163 *
164 * @return bool
165 */
166 public function isStarted();
167
168 /**
169 * Get the previous URL from the session.
170 *
171 * @return string|null
172 */
173 public function previousUrl();
174
175 /**
176 * Set the "previous" URL in the session.
177 *
178 * @param string $url
179 * @return void
180 */
181 public function setPreviousUrl($url);
182
183 /**
184 * Get the session handler instance.
185 *
186 * @return \SessionHandlerInterface
187 */
188 public function getHandler();
189
190 /**
191 * Determine if the session handler needs a request.
192 *
193 * @return bool
194 */
195 public function handlerNeedsRequest();
196
197 /**
198 * Set the request on the handler instance.
199 *
200 * @param \Illuminate\Http\Request $request
201 * @return void
202 */
203 public function setRequestOnHandler($request);
204}