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