-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession.php
52 lines (47 loc) · 1.4 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
<?php declare(strict_types = 1);
namespace noxkiwi\core;
use noxkiwi\core\Interfaces\SessionInterface;
use noxkiwi\core\Traits\HookTrait;
use noxkiwi\singleton\Singleton;
use function session_id;
/**
* I am the base session class. All session objects must be my children.
*
* @package noxkiwi\core
* @author Jan Nox <[email protected]>
* @license https://nox.kiwi/license
* @copyright 2016 - 2021 noxkiwi
* @version 1.0.2
* @link https://nox.kiwi/
*/
abstract class Session extends Singleton implements SessionInterface
{
use HookTrait;
protected const USE_DRIVER = true;
public const SESSIONKEY = 'phpsessid';
public const HOOK_DESTROYED = 'session_destroyed';
public const HOOK_STARTED = 'session_started';
/**
* I will construct the Session adding the given $data into the Session.
*
* Note: To CREATE a re-useable Session object, you'll need to call >create as shown in the example.
* @examle
* $session = Session::getInstance();
* $session->create($data)
*
* @param array $data
*/
protected function __construct(array $data = [])
{
parent::__construct();
$this->add($data);
}
/**
* I will return the identifier of this session.
* @return string
*/
public static function getIdentifier(): string
{
return session_id();
}
}