-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession.php
More file actions
executable file
·36 lines (31 loc) · 825 Bytes
/
Copy pathSession.php
File metadata and controls
executable file
·36 lines (31 loc) · 825 Bytes
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
<?php
namespace Pet\Session;
class Session
{
public $status;
public static $name = 'PET/SESSION' ;
public function __construct()
{
$this->status = $this->init();
}
private function init() {
$status = session_status();
if ( $status == PHP_SESSION_NONE && $status != PHP_SESSION_DISABLED){
session_start(['name' => self::$name]);
}
return session_status();
}
public static function get(string|null $key = null): string|array|null
{
if (!$key) return $_SESSION;
return !empty($_SESSION[$key])?$_SESSION[$key]: null;
}
public static function set(array|object $val): void
{
foreach ($val as $i => $v) $_SESSION[$i] = $v;
}
public static function kill()
{
session_destroy();
}
}