Skip to content

Instantly share code, notes, and snippets.

@igorw
Created January 23, 2010 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorw/284690 to your computer and use it in GitHub Desktop.
Save igorw/284690 to your computer and use it in GitHub Desktop.
<?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