00001 <?php 00002 00020 // $Id: Session.inc.php,v 1.10 2008/07/01 01:16:10 asmecher Exp $ 00021 00022 00023 class Session extends DataObject { 00024 00026 var $user; 00027 00031 function Session() { 00032 parent::DataObject(); 00033 } 00034 00040 function getSessionVar($key) { 00041 return isset($_SESSION[$key]) ? $_SESSION[$key] : null; 00042 } 00043 00050 function setSessionVar($key, $value) { 00051 $_SESSION[$key] = $value; 00052 return $value; 00053 } 00054 00059 function unsetSessionVar($key) { 00060 if (isset($_SESSION[$key])) { 00061 unset($_SESSION[$key]); 00062 } 00063 00064 if (session_is_registered($key)) { 00065 session_unregister($key); 00066 } 00067 } 00068 00069 // 00070 // Get/set methods 00071 // 00072 00077 function getId() { 00078 return $this->getData('id'); 00079 } 00080 00085 function setId($id) { 00086 return $this->setData('id', $id); 00087 } 00088 00093 function getUserId() { 00094 return $this->getData('userId'); 00095 } 00096 00101 function setUserId($userId) { 00102 if (!isset($userId) || empty($userId)) { 00103 $this->user = null; 00104 $userId = null; 00105 00106 } else if ($userId != $this->getData('userId')) { 00107 $userDao = &DAORegistry::getDAO('UserDAO'); 00108 $this->user = &$userDao->getUser($userId); 00109 if (!isset($this->user)) { 00110 $userId = null; 00111 } 00112 } 00113 return $this->setData('userId', $userId); 00114 } 00115 00120 function getIpAddress() { 00121 return $this->getData('ipAddress'); 00122 } 00123 00128 function setIpAddress($ipAddress) { 00129 return $this->setData('ipAddress', $ipAddress); 00130 } 00131 00136 function getUserAgent() { 00137 return $this->getData('userAgent'); 00138 } 00139 00144 function setUserAgent($userAgent) { 00145 return $this->setData('userAgent', $userAgent); 00146 } 00147 00152 function getSecondsCreated() { 00153 return $this->getData('created'); 00154 } 00155 00160 function setSecondsCreated($created) { 00161 return $this->setData('created', $created); 00162 } 00163 00168 function getSecondsLastUsed() { 00169 return $this->getData('lastUsed'); 00170 } 00171 00176 function setSecondsLastUsed($lastUsed) { 00177 return $this->setData('lastUsed', $lastUsed); 00178 } 00179 00184 function getRemember() { 00185 return $this->getData('remember'); 00186 } 00187 00192 function setRemember($remember) { 00193 return $this->setData('remember', $remember); 00194 } 00195 00200 function getSessionData() { 00201 return $this->getData('data'); 00202 } 00203 00208 function setSessionData($data) { 00209 return $this->setData('data', $data); 00210 } 00211 00216 function &getUser() { 00217 return $this->user; 00218 } 00219 00220 } 00221 00222 ?>
1.5.6