File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 30
30
*
31
31
* @package doganoo\PHPUtil\HTTP
32
32
*/
33
- class Session {
33
+ class Session implements \JsonSerializable {
34
+ private $ started = false ;
35
+
34
36
/**
35
37
* Session constructor.
36
38
*/
@@ -39,7 +41,7 @@ public function __construct() {
39
41
* see: https://stackoverflow.com/a/17399989
40
42
*/
41
43
if (session_id () == '' || !isset ($ _SESSION )) {
42
- session_start ();
44
+ $ this -> started = session_start ();
43
45
}
44
46
}
45
47
@@ -117,4 +119,22 @@ public function set($index, $value) {
117
119
public function regenerateSessionId () {
118
120
session_regenerate_id (true );
119
121
}
122
+
123
+ /**
124
+ * @return bool
125
+ */
126
+ public function isStarted (): bool {
127
+ return $ this ->started ;
128
+ }
129
+
130
+ /**
131
+ * Specify data which should be serialized to JSON
132
+ * @link https://php.net/manual/en/jsonserializable.jsonserialize.php
133
+ * @return mixed data which can be serialized by <b>json_encode</b>,
134
+ * which is a value of any type other than a resource.
135
+ * @since 5.4.0
136
+ */
137
+ public function jsonSerialize () {
138
+ return $ _SESSION ;
139
+ }
120
140
}
You can’t perform that action at this time.
0 commit comments