Created
January 23, 2010 17:05
-
-
Save igorw/284690 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class session_storage | |
{ | |
protected $session_id; | |
protected $db; | |
protected $user; | |
public function __construct($session_id, dbal $db, user $user) | |
{ | |
$this->session_id = $session_id; | |
$this->db = $db; | |
$this->user = $user; | |
} | |
public function get($var) | |
{ | |
return $this->user->data[$var]; | |
} | |
public function set($var, $value) | |
{ | |
$sql = 'UPDATE ' . SESSIONS_TABLE . ' | |
SET ' . $var . ' = \'' . $this->db->sql_escape($value) . '\' | |
WHERE session_id = \'' . $this->db->sql_escape($this->session_id) . '\''; | |
$this->db->sql_query($sql); | |
$this->user->data[$var] = $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment