-
Notifications
You must be signed in to change notification settings - Fork 0
/
Session.php
56 lines (49 loc) · 1.07 KB
/
Session.php
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
<?php
/**
* Definition of class Session
*
* @copyright 2015-today Justso GmbH
* @author [email protected]
* @package justso\justapi
*/
namespace justso\justapi;
/**
* This class abstracts php session handling to prevent usage of super globals and instead use a normal object
*
* @codeCoverageIgnore
*/
class Session implements SessionInterface
{
public function getValue($name)
{
$this->activate();
return $_SESSION[$name];
}
public function setValue($name, $value)
{
$this->activate();
$_SESSION[$name] = $value;
}
public function unsetValue($name)
{
if ($this->isValueSet($name)) {
unset($_SESSION[$name]);
}
}
public function getId()
{
$this->activate();
return session_id();
}
public function isValueSet($name)
{
$this->activate();
return isset($_SESSION[$name]);
}
public function activate()
{
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
}
}