]> git.mxchange.org Git - friendica.git/blob - src/Core/Session/AbstractSession.php
Merge pull request #8022 from nupplaphil/task/mod_hcard
[friendica.git] / src / Core / Session / AbstractSession.php
1 <?php
2
3
4 namespace Friendica\Core\Session;
5
6 /**
7  * Contains the base methods for $_SESSION interaction
8  */
9 class AbstractSession
10 {
11         /**
12          * {@inheritDoc}
13          */
14         public function start()
15         {
16                 return $this;
17         }
18
19         /**
20          * {@inheritDoc}}
21          */
22         public function exists(string $name)
23         {
24                 return isset($_SESSION[$name]);
25         }
26
27         /**
28          * {@inheritDoc}
29          */
30         public function get(string $name, $defaults = null)
31         {
32                 return $_SESSION[$name] ?? $defaults;
33         }
34
35         /**
36          * {@inheritDoc}
37          */
38         public function set(string $name, $value)
39         {
40                 $_SESSION[$name] = $value;
41         }
42
43         /**
44          * {@inheritDoc}
45          */
46         public function setMultiple(array $values)
47         {
48                 $_SESSION = $values + $_SESSION;
49         }
50
51         /**
52          * {@inheritDoc}
53          */
54         public function remove(string $name)
55         {
56                 unset($_SESSION[$name]);
57         }
58
59         /**
60          * {@inheritDoc}
61          */
62         public function clear()
63         {
64                 $_SESSION = [];
65         }
66 }