XOOPS  2.6.0
Session.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  */
11 
12 namespace Xmf\Module;
13 
15 
32 class Session extends AbstractHelper
33 {
37  private $prefix;
38 
44  public function init()
45  {
46  $this->prefix = $this->module->getVar('dirname') . '_';
47  }
48 
56  private function prefix($name)
57  {
58  $prefixedName = $this->prefix . $name;
59 
60  return $prefixedName;
61  }
62 
71  public function set($name, $value)
72  {
73  $prefixedName = $this->prefix($name);
74  $_SESSION[$prefixedName] = serialize($value);
75  }
76 
84  public function get($name)
85  {
86  $prefixedName = $this->prefix($name);
87  if (isset($_SESSION[$prefixedName])) {
88  return unserialize($_SESSION[$prefixedName]);
89  } else {
90  return false;
91  }
92  }
93 
101  public function del($name)
102  {
103  $prefixedName = $this->prefix($name);
104  $_SESSION[$prefixedName] = null;
105  unset($_SESSION[$prefixedName]);
106  }
107 
113  public function destroy()
114  {
115  foreach ($_SESSION as $key => $value) {
116  if (0 == substr_compare($key, $this->prefix, 0, strlen($this->prefix))) {
117  $_SESSION[$key] = null;
118  unset($_SESSION[$key]);
119  }
120  }
121  }
122 }
$_SESSION['RF']["verify"]
Definition: dialog.php:4
set($name, $value)
Definition: Session.php:71