ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
57
58 $ilDB = $DIC['ilDB'];
59
60 if (!is_array(self::$values[$this->component_id])) {
62 }
63 self::$values[$this->component_id][$a_key] = $a_val;
64 $ilDB->replace(
65 "usr_sess_istorage",
66 array(
67 "session_id" => array("text", $this->session_id),
68 "component_id" => array("text", $this->component_id),
69 "vkey" => array("text", $a_key)
70 ),
71 array("value" => array("text", $a_val))
72 );
73 }
74
80 public function get($a_key)
81 {
82 global $DIC;
83
84 $ilDB = $DIC['ilDB'];
85
86 if (is_array(self::$values[$this->component_id]) &&
87 isset(self::$values[$this->component_id][$a_key])) {
88 return self::$values[$this->component_id][$a_key];
89 }
90
91 $set = $ilDB->query(
92 "SELECT value FROM usr_sess_istorage " .
93 " WHERE session_id = " . $ilDB->quote($this->session_id, "text") .
94 " AND component_id = " . $ilDB->quote($this->component_id, "text") .
95 " AND vkey = " . $ilDB->quote($a_key, "text")
96 );
97 $rec = $ilDB->fetchAssoc($set);
98 self::$values[$this->component_id][$a_key] = $rec["value"];
99
100 return $rec["value"];
101 }
102
109 public static function destroySession($a_session_id)
110 {
111 global $DIC;
112
113 $ilDB = $DIC['ilDB'];
114
115 if (!is_array($a_session_id)) {
116 $q = "DELETE FROM usr_sess_istorage WHERE session_id = " .
117 $ilDB->quote($a_session_id, "text");
118 } else {
119 $q = "DELETE FROM usr_sess_istorage WHERE " .
120 $ilDB->in("session_id", $a_session_id, "", "text");
121 }
122
123 $ilDB->manipulate($q);
124 }
125}
An exception for terminatinating execution or to throw for unit testing.
Session based immediate storage.
__construct($a_component_id, $a_sess_id="")
Constructor.
static destroySession($a_session_id)
Destroy session(s).
global $DIC
Definition: saml.php:7
global $ilDB
$values