ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSessionIStorage.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
28 {
29  protected $session_id = "";
30  protected $component_id = "";
31  protected static $values = array();
32 
39  public function __construct($a_component_id, $a_sess_id = "")
40  {
41  $this->component_id = $a_component_id;
42  if ($a_sess_id != "") {
43  $this->session_id = $a_sess_id;
44  } else {
45  $this->session_id = session_id();
46  }
47  }
48 
54  public function set($a_key, $a_val)
55  {
56  global $ilDB;
57 
58  if (!is_array(self::$values[$this->component_id])) {
59  self::$values[$this->component_id] = array();
60  }
61  self::$values[$this->component_id][$a_key] = $a_val;
62  $ilDB->replace(
63  "usr_sess_istorage",
64  array(
65  "session_id" => array("text", $this->session_id),
66  "component_id" => array("text", $this->component_id),
67  "vkey" => array("text", $a_key)
68  ),
69  array("value" => array("text", $a_val))
70  );
71  }
72 
78  public function get($a_key)
79  {
80  global $ilDB;
81 
82  if (is_array(self::$values[$this->component_id]) &&
83  isset(self::$values[$this->component_id][$a_key])) {
84  return self::$values[$this->component_id][$a_key];
85  }
86 
87  $set = $ilDB->query(
88  "SELECT value FROM usr_sess_istorage " .
89  " WHERE session_id = " . $ilDB->quote($this->session_id, "text") .
90  " AND component_id = " . $ilDB->quote($this->component_id, "text") .
91  " AND vkey = " . $ilDB->quote($a_key, "text")
92  );
93  $rec = $ilDB->fetchAssoc($set);
94  self::$values[$this->component_id][$a_key] = $rec["value"];
95 
96  return $rec["value"];
97  }
98 
105  public static function destroySession($a_session_id)
106  {
107  global $ilDB;
108 
109  if (!is_array($a_session_id)) {
110  $q = "DELETE FROM usr_sess_istorage WHERE session_id = " .
111  $ilDB->quote($a_session_id, "text");
112  } else {
113  $q = "DELETE FROM usr_sess_istorage WHERE " .
114  $ilDB->in("session_id", $a_session_id, "", "text");
115  }
116 
117  $ilDB->manipulate($q);
118  }
119 }
__construct($a_component_id, $a_sess_id="")
Constructor.
static destroySession($a_session_id)
Destroy session(s).
Create styles array
The data for the language used.
global $ilDB
Session based immediate storage.