forked from SignalByNick/session-lock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionManagerInterface.php
More file actions
158 lines (144 loc) · 5.38 KB
/
Copy pathSessionManagerInterface.php
File metadata and controls
158 lines (144 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php declare(strict_types=1);
/**
* Session - Securely manage and preserve session data.
*
* @license MIT License. (https://github.com/Commander-Ant-Screwbin-Games/session/blob/master/license)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* https://github.com/Commander-Ant-Screwbin-Games/firecms/tree/master/src/Core
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @package Commander-Ant-Screwbin-Games/session.
*/
namespace Session;
/**
* Secure session management.
*
* You can start a session using the static method `SessionManager::start(...)` which
* is compatible to PHP's built-in `session_start()` function.
*
* @interface SessionManagerInterface.
*/
interface SessionManagerInterface
{
/**
* Construct a new session manager.
*
* @param array $options The session manager options.
* @param bool $exceptions Should we utilize exceptions.
*
* @return void Returns nothing.
*/
public function __construct(array $options = [], bool $exceptions = \true);
/**
* Set the session manager options.
*
* @param array $options The session manager options.
*
* @return \Session\SessionManagerInterface Returns the session manager.
*/
public function setOptions(array $options = []): SessionManagerInterface;
/**
* Set the exceptions param.
*
* @param bool $exceptions Should we utilize exceptions.
*
* @return \Session\SessionManagerInterface Returns the session manager.
*/
public function setExceptions(bool $exceptions = \true): SessionManagerInterface;
/**
* Starts or resumes a session.
*
* @throws Exception\InvalidFingerprintException If the fingerprint from the user does not match the one
* binded to the session.
*
* @return bool Returns true on success or false on failure.
*/
public function start(): bool;
/**
* Stop a session and destroys all data.
*
* @return bool Returns true on success or false on failure.
*/
public function stop(): bool;
/**
* Check to see if a session already exists.
*
* @return bool Returns true if one exists and false if not.
*/
public static function exists(): bool;
/**
* Regenerates the session.
*
* @param bool $deleteOldSession Whether to delete the old session or not.
*
* @return bool Returns true on success or false on failure.
*/
public static function regenerate(bool $deleteOldSession = \true): bool;
/**
* Checks whether a value for the specified key exists in the session.
*
* @param string $key The key to check.
*
* @return bool Returns true if the key was found and false if not.
*/
public function has(string $key): bool;
/**
* Returns the requested value from the session or, if not found, the
* specified default value.
*
* @param string $key The key to retrieve the value for.
* @param mixed $defaultValue The default value to return if the
* requested value cannot be found.
*
* @return mixed Returns the requested value or the default
* value.
*/
public static function get(string $key, $defaultValue = \null);
/**
* Returns the requested value and removes it from the session.
*
* This is identical to calling `get` first and then `remove` for the same
* key.
*
* @param string $key The key to retrieve and remove the value for.
* @param mixed $defaultValue The default value to return if the requested
* value cannot be found.
*
* @return mixed The requested value or the default value.
*/
public static function flash(string $key, $defaultValue = \null);
/**
* Sets the value for the specified key to the given value.
*
* Any data that already exists for the specified key will be overwritten.
*
* @param string $key The key to set the value for.
* @param mixed $value The value to set.
*
* @return void Returns nothing.
*/
public static function put(string $key, $value): void;
/**
* Removes the value for the specified key from the session.
*
* @param string $key The key to remove the value for.
*
* @return void Returns nothing.
*/
public static function delete(string $key): void;
}