Add sensitive variable support to Session, cleared on login

This commit is contained in:
2012-01-16 00:18:19 +00:00
parent 1d8609573b
commit c4c262a6c3

View File

@@ -7,11 +7,13 @@ class SihnonFramework_Session {
protected $enabled;
protected $state;
protected $dirty;
protected $sensitive;
public function __construct(Sihnon_Config $config) {
$this->config = $config;
$this->enabled = false;
$this->dirty = false;
$this->sensitive = array();
if ($this->config->exists('sessions') && $this->config->get('sessions')) {
$this->enabled = true;
@@ -47,8 +49,12 @@ class SihnonFramework_Session {
}
}
public function set($name, $value) {
public function set($name, $value, $sensitive = false) {
$this->state[$name] = $value;
if ($sensitive) {
$this->sensitive[$name] = true;
}
$this->dirty = true;
}
@@ -73,6 +79,14 @@ class SihnonFramework_Session {
if ($this->enabled) {
session_regenerate_id(true);
}
// Clear any sensitive values
foreach ($this->sensitive as $name => $value) {
if ($value) {
$this->delete($name);
}
}
$this->sensitive = array();
}
}