1 | <?php |
||
4 | class SessionPersistentDataStore implements PersistentDataStoreInterface |
||
5 | { |
||
6 | |||
7 | /** |
||
8 | * Session Variable Prefix |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $prefix; |
||
13 | |||
14 | /** |
||
15 | * Create a new SessionPersistentDataStore instance |
||
16 | * |
||
17 | * @param string $prefix Session Variable Prefix |
||
18 | */ |
||
19 | public function __construct($prefix = 'DBAPI_') |
||
24 | |||
25 | /** |
||
26 | * Start session if not started previously |
||
27 | */ |
||
28 | protected function start() |
||
29 | { |
||
30 | if (!isset($_SESSION) && !headers_sent()) { |
||
31 | session_start(); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Get a value from the store |
||
37 | * |
||
38 | * @param string $key Data Key |
||
39 | * |
||
40 | * @return string|null |
||
41 | */ |
||
42 | public function get($key) |
||
50 | |||
51 | /** |
||
52 | * Set a value in the store |
||
53 | * @param string $key Data Key |
||
54 | * @param string $value Data Value |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public function set($key, $value) |
||
62 | |||
63 | /** |
||
64 | * Clear the key from the store |
||
65 | * |
||
66 | * @param $key Data Key |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | public function clear($key) |
||
76 | } |
||
77 |