1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* KumbiaPHP web & app Framework |
5
|
|
|
* |
6
|
|
|
* LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
9
|
|
|
* with this package in the file LICENSE.txt. |
10
|
|
|
* It is also available through the world-wide-web at this URL: |
11
|
|
|
* http://wiki.kumbiaphp.com/Licencia |
12
|
|
|
* If you did not receive a copy of the license and are unable to |
13
|
|
|
* obtain it through the world-wide-web, please send an email |
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
15
|
|
|
* |
16
|
|
|
* @category Kumbia |
17
|
|
|
* @package Session |
18
|
|
|
* @copyright Copyright (c) 2005 - 2017 Kumbia Team (http://www.kumbiaphp.com) |
19
|
|
|
* @license http://wiki.kumbiaphp.com/Licencia New BSD License |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Modelo orientado a objetos para el acceso a datos en Sesiones |
25
|
|
|
* |
26
|
|
|
* @category Kumbia |
27
|
|
|
* @package Session |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/*Session start*/ |
32
|
|
|
if (session_status() !== PHP_SESSION_ACTIVE) { |
33
|
|
|
session_start(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
class Session |
37
|
|
|
{ |
38
|
|
|
const SESSION = 'KUMBIA_SESSION'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Crear o especificar el valor para un indice de la sesión |
42
|
|
|
* actual |
43
|
|
|
* |
44
|
|
|
* @param string $index |
45
|
|
|
* @param string $namespace |
46
|
|
|
*/ |
47
|
|
|
public static function set($index, $value, $namespace = 'default') |
48
|
|
|
{ |
49
|
|
|
$_SESSION[SESSION][APP_PATH][$namespace][$index] = $value; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Obtener el valor para un indice de la sesión |
55
|
|
|
* |
56
|
|
|
* @param string $index |
57
|
|
|
* @param string $namespace |
58
|
|
|
* @return mixed |
59
|
|
|
*/ |
60
|
|
|
public static function get($index, $namespace='default') |
61
|
|
|
{ |
62
|
|
|
if (isset($_SESSION[SESSION][APP_PATH][$namespace][$index])) { |
63
|
|
|
return $_SESSION[SESSION][APP_PATH][$namespace][$index]; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Elimina un indice |
70
|
|
|
* |
71
|
|
|
* @param string $index |
72
|
|
|
* @param string $namespace |
73
|
|
|
*/ |
74
|
|
|
public static function delete($index, $namespace='default') |
75
|
|
|
{ |
76
|
|
|
unset($_SESSION[SESSION][APP_PATH][$namespace][$index]); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Verifica si el indice esta cargado en sesión |
82
|
|
|
* |
83
|
|
|
* @param string $index |
84
|
|
|
* @param string $namespace |
85
|
|
|
* @return boolean |
86
|
|
|
*/ |
87
|
|
|
public static function has($index, $namespace='default') |
88
|
|
|
{ |
89
|
|
|
return isset($_SESSION[SESSION][APP_PATH][$namespace][$index]); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
|