Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
| 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
| 6 | * |
| 7 | * NOTICE OF LICENSE |
| 8 | * |
| 9 | * Licensed under the Open Software License version 3.0 |
| 10 | * |
| 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 18 | * |
| 19 | * @package CodeIgniter |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
| 21 | * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc. |
| 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 2.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 28 | /** |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 29 | * CodeIgniter Session Class |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 30 | * |
| 31 | * The user interface defined by EllisLabs, now with puggable drivers to manage different storage mechanisms. |
dchill42 | 0e88408 | 2012-08-11 20:10:17 -0400 | [diff] [blame] | 32 | * By default, the cookie session driver will load, but the 'sess_driver' config/param item (see above) can be |
| 33 | * used to specify the 'native' driver, or any other you might create. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 34 | * Once loaded, this driver setup is a drop-in replacement for the former CI_Session library, taking its place as the |
| 35 | * 'session' member of the global controller framework (e.g.: $CI->session or $this->session). |
| 36 | * In keeping with the CI_Driver methodology, multiple drivers may be loaded, although this might be a bit confusing. |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 37 | * The CI_Session library class keeps track of the most recently loaded driver as "current" to call for driver methods. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 38 | * Ideally, one driver is loaded and all calls go directly through the main library interface. However, any methods |
| 39 | * called through the specific driver will switch the "current" driver to itself before invoking the library method |
| 40 | * (which will then call back into the driver for low-level operations). So, alternation between two drivers can be |
| 41 | * achieved by specifying which driver to use for each call (e.g.: $this->session->native->set_userdata('foo', 'bar'); |
| 42 | * $this->session->cookie->userdata('foo'); $this->session->native->unset_userdata('foo');). Notice in the previous |
| 43 | * example that the _native_ userdata value 'foo' would be set to 'bar', which would NOT be returned by the call for |
| 44 | * the _cookie_ userdata 'foo', nor would the _cookie_ value be unset by the call to unset the _native_ 'foo' value. |
| 45 | * |
| 46 | * @package CodeIgniter |
| 47 | * @subpackage Libraries |
| 48 | * @category Sessions |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 49 | * @author EllisLab Dev Team |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 50 | * @link http://codeigniter.com/user_guide/libraries/sessions.html |
| 51 | */ |
Darren Hill | a2ae657 | 2011-09-01 07:36:26 -0400 | [diff] [blame] | 52 | class CI_Session extends CI_Driver_Library { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 53 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 54 | public $params = array(); |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 55 | protected $current = NULL; |
Darren Hill | a2ae657 | 2011-09-01 07:36:26 -0400 | [diff] [blame] | 56 | protected $userdata = array(); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 57 | |
| 58 | const FLASHDATA_KEY = 'flash'; |
| 59 | const FLASHDATA_NEW = ':new:'; |
| 60 | const FLASHDATA_OLD = ':old:'; |
| 61 | const FLASHDATA_EXP = ':exp:'; |
| 62 | const EXPIRATION_KEY = '__expirations'; |
| 63 | const TEMP_EXP_DEF = 300; |
| 64 | |
| 65 | /** |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 66 | * CI_Session constructor |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 67 | * |
| 68 | * The constructor loads the configured driver ('sess_driver' in config.php or as a parameter), running |
| 69 | * routines in its constructor, and manages flashdata aging. |
| 70 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 71 | * @param array Configuration parameters |
Andrey Andreev | 2e3e230 | 2012-10-09 15:52:34 +0300 | [diff] [blame^] | 72 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 73 | */ |
| 74 | public function __construct(array $params = array()) |
| 75 | { |
Andrey Andreev | 2e3e230 | 2012-10-09 15:52:34 +0300 | [diff] [blame^] | 76 | $CI =& get_instance(); |
| 77 | |
| 78 | // No sessions under CLI |
| 79 | if ($CI->input->is_cli_request()) |
| 80 | { |
| 81 | return; |
| 82 | } |
| 83 | |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 84 | log_message('debug', 'CI_Session Class Initialized'); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 85 | |
| 86 | // Get valid drivers list |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 87 | $this->valid_drivers = array( |
| 88 | 'Session_native', |
| 89 | 'Session_cookie' |
| 90 | ); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 91 | $key = 'sess_valid_drivers'; |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 92 | $drivers = isset($params[$key]) ? $params[$key] : $CI->config->item($key); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 93 | if ($drivers) |
| 94 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 95 | is_array($drivers) OR $drivers = array($drivers); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 96 | |
| 97 | // Add driver names to valid list |
| 98 | foreach ($drivers as $driver) |
| 99 | { |
dchill42 | 77ee3fd | 2012-07-24 11:50:01 -0400 | [diff] [blame] | 100 | if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 101 | { |
| 102 | $this->valid_drivers[] = $driver; |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | // Get driver to load |
| 108 | $key = 'sess_driver'; |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 109 | $driver = isset($params[$key]) ? $params[$key] : $CI->config->item($key); |
| 110 | if ( ! $driver) |
| 111 | { |
| 112 | $driver = 'cookie'; |
| 113 | } |
| 114 | |
dchill42 | 77ee3fd | 2012-07-24 11:50:01 -0400 | [diff] [blame] | 115 | if ( ! in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers))) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 116 | { |
| 117 | $this->valid_drivers[] = 'Session_'.$driver; |
| 118 | } |
| 119 | |
| 120 | // Save a copy of parameters in case drivers need access |
| 121 | $this->params = $params; |
| 122 | |
| 123 | // Load driver and get array reference |
| 124 | $this->load_driver($driver); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 125 | |
| 126 | // Delete 'old' flashdata (from last request) |
| 127 | $this->_flashdata_sweep(); |
| 128 | |
| 129 | // Mark all new flashdata as old (data will be deleted before next request) |
| 130 | $this->_flashdata_mark(); |
| 131 | |
| 132 | // Delete expired tempdata |
| 133 | $this->_tempdata_sweep(); |
| 134 | |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 135 | log_message('debug', 'CI_Session routines successfully run'); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 136 | } |
| 137 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 138 | // ------------------------------------------------------------------------ |
| 139 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 140 | /** |
| 141 | * Loads session storage driver |
| 142 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 143 | * @param string Driver classname |
| 144 | * @return object Loaded driver object |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 145 | */ |
| 146 | public function load_driver($driver) |
| 147 | { |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 148 | // Save reference to most recently loaded driver as library default and sync userdata |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 149 | $this->current = parent::load_driver($driver); |
dchill42 | b185537 | 2012-07-31 09:32:23 -0400 | [diff] [blame] | 150 | $this->userdata =& $this->current->get_userdata(); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 151 | return $this->current; |
| 152 | } |
| 153 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 154 | // ------------------------------------------------------------------------ |
| 155 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 156 | /** |
| 157 | * Select default session storage driver |
| 158 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 159 | * @param string Driver classname |
| 160 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 161 | */ |
| 162 | public function select_driver($driver) |
| 163 | { |
| 164 | // Validate driver name |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 165 | $lowername = strtolower(str_replace('CI_', '', $driver)); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 166 | if (in_array($lowername, array_map('strtolower', $this->valid_drivers))) |
| 167 | { |
dchill42 | b185537 | 2012-07-31 09:32:23 -0400 | [diff] [blame] | 168 | // See if driver is loaded |
| 169 | $child = str_replace($this->lib_name.'_', '', $driver); |
| 170 | if (isset($this->$child)) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 171 | { |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 172 | // See if driver is already current |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 173 | if ($this->$child !== $this->current) |
| 174 | { |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 175 | // Make driver current and sync userdata |
| 176 | $this->current = $this->$child; |
| 177 | $this->userdata =& $this->current->get_userdata(); |
| 178 | } |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 179 | } |
| 180 | else |
| 181 | { |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 182 | // Load new driver |
dchill42 | aee9265 | 2012-08-26 21:45:35 -0400 | [diff] [blame] | 183 | $this->load_driver($child); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 188 | // ------------------------------------------------------------------------ |
| 189 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 190 | /** |
| 191 | * Destroy the current session |
| 192 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 193 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 194 | */ |
| 195 | public function sess_destroy() |
| 196 | { |
| 197 | // Just call destroy on driver |
| 198 | $this->current->sess_destroy(); |
| 199 | } |
| 200 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 201 | // ------------------------------------------------------------------------ |
| 202 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 203 | /** |
| 204 | * Regenerate the current session |
| 205 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 206 | * @param bool Destroy session data flag (default: false) |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 207 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 208 | */ |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 209 | public function sess_regenerate($destroy = FALSE) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 210 | { |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 211 | // Call regenerate on driver and resync userdata |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 212 | $this->current->sess_regenerate($destroy); |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 213 | $this->userdata =& $this->current->get_userdata(); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 214 | } |
| 215 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 216 | // ------------------------------------------------------------------------ |
| 217 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 218 | /** |
| 219 | * Fetch a specific item from the session array |
| 220 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 221 | * @param string Item key |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 222 | * @return string Item value or NULL if not found |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 223 | */ |
| 224 | public function userdata($item) |
| 225 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 226 | return isset($this->userdata[$item]) ? $this->userdata[$item] : NULL; |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 227 | } |
| 228 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 229 | // ------------------------------------------------------------------------ |
| 230 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 231 | /** |
| 232 | * Fetch all session data |
| 233 | * |
| 234 | * @return array User data array |
| 235 | */ |
| 236 | public function all_userdata() |
| 237 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 238 | return isset($this->userdata) ? $this->userdata : NULL; |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 239 | } |
| 240 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 241 | // ------------------------------------------------------------------------ |
| 242 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 243 | /** |
dchill42 | c5079de | 2012-07-23 10:53:47 -0400 | [diff] [blame] | 244 | * Fetch all flashdata |
| 245 | * |
| 246 | * @return array Flash data array |
| 247 | */ |
| 248 | public function all_flashdata() |
| 249 | { |
| 250 | $out = array(); |
| 251 | |
| 252 | // loop through all userdata |
| 253 | foreach ($this->all_userdata() as $key => $val) |
| 254 | { |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 255 | // if it contains flashdata, add it |
dchill42 | c5079de | 2012-07-23 10:53:47 -0400 | [diff] [blame] | 256 | if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE) |
| 257 | { |
dchill42 | 2642920 | 2012-07-31 10:55:07 -0400 | [diff] [blame] | 258 | $key = str_replace(self::FLASHDATA_KEY.self::FLASHDATA_OLD, '', $key); |
dchill42 | c5079de | 2012-07-23 10:53:47 -0400 | [diff] [blame] | 259 | $out[$key] = $val; |
| 260 | } |
| 261 | } |
| 262 | return $out; |
| 263 | } |
| 264 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 265 | // ------------------------------------------------------------------------ |
| 266 | |
dchill42 | c5079de | 2012-07-23 10:53:47 -0400 | [diff] [blame] | 267 | /** |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 268 | * Add or change data in the "userdata" array |
| 269 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 270 | * @param mixed Item name or array of items |
| 271 | * @param string Item value or empty string |
| 272 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 273 | */ |
| 274 | public function set_userdata($newdata = array(), $newval = '') |
| 275 | { |
| 276 | // Wrap params as array if singular |
| 277 | if (is_string($newdata)) |
| 278 | { |
| 279 | $newdata = array($newdata => $newval); |
| 280 | } |
| 281 | |
| 282 | // Set each name/value pair |
| 283 | if (count($newdata) > 0) |
| 284 | { |
| 285 | foreach ($newdata as $key => $val) |
| 286 | { |
| 287 | $this->userdata[$key] = $val; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | // Tell driver data changed |
| 292 | $this->current->sess_save(); |
| 293 | } |
| 294 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 295 | // ------------------------------------------------------------------------ |
| 296 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 297 | /** |
| 298 | * Delete a session variable from the "userdata" array |
| 299 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 300 | * @param mixed Item name or array of item names |
| 301 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 302 | */ |
| 303 | public function unset_userdata($newdata = array()) |
| 304 | { |
| 305 | // Wrap single name as array |
| 306 | if (is_string($newdata)) |
| 307 | { |
| 308 | $newdata = array($newdata => ''); |
| 309 | } |
| 310 | |
| 311 | // Unset each item name |
| 312 | if (count($newdata) > 0) |
| 313 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 314 | foreach (array_keys($newdata) as $key) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 315 | { |
| 316 | unset($this->userdata[$key]); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | // Tell driver data changed |
| 321 | $this->current->sess_save(); |
| 322 | } |
| 323 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 324 | // ------------------------------------------------------------------------ |
| 325 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 326 | /** |
| 327 | * Determine if an item exists |
| 328 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 329 | * @param string Item name |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 330 | * @return bool |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 331 | */ |
| 332 | public function has_userdata($item) |
| 333 | { |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 334 | return isset($this->userdata[$item]); |
| 335 | } |
| 336 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 337 | // ------------------------------------------------------------------------ |
| 338 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 339 | /** |
| 340 | * Add or change flashdata, only available until the next request |
| 341 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 342 | * @param mixed Item name or array of items |
| 343 | * @param string Item value or empty string |
| 344 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 345 | */ |
| 346 | public function set_flashdata($newdata = array(), $newval = '') |
| 347 | { |
| 348 | // Wrap item as array if singular |
| 349 | if (is_string($newdata)) |
| 350 | { |
| 351 | $newdata = array($newdata => $newval); |
| 352 | } |
| 353 | |
| 354 | // Prepend each key name and set value |
| 355 | if (count($newdata) > 0) |
| 356 | { |
| 357 | foreach ($newdata as $key => $val) |
| 358 | { |
| 359 | $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; |
| 360 | $this->set_userdata($flashdata_key, $val); |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 365 | // ------------------------------------------------------------------------ |
| 366 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 367 | /** |
| 368 | * Keeps existing flashdata available to next request. |
| 369 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 370 | * @param string Item key |
| 371 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 372 | */ |
| 373 | public function keep_flashdata($key) |
| 374 | { |
dchill42 | c5079de | 2012-07-23 10:53:47 -0400 | [diff] [blame] | 375 | // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep() |
| 376 | // Note the function will return NULL if the $key provided cannot be found |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 377 | $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; |
| 378 | $value = $this->userdata($old_flashdata_key); |
| 379 | |
| 380 | $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; |
| 381 | $this->set_userdata($new_flashdata_key, $value); |
| 382 | } |
| 383 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 384 | // ------------------------------------------------------------------------ |
| 385 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 386 | /** |
| 387 | * Fetch a specific flashdata item from the session array |
| 388 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 389 | * @param string Item key |
| 390 | * @return string |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 391 | */ |
| 392 | public function flashdata($key) |
| 393 | { |
| 394 | // Prepend key and retrieve value |
| 395 | $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; |
| 396 | return $this->userdata($flashdata_key); |
| 397 | } |
| 398 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 399 | // ------------------------------------------------------------------------ |
| 400 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 401 | /** |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 402 | * Add or change tempdata, only available until expiration |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 403 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 404 | * @param mixed Item name or array of items |
| 405 | * @param string Item value or empty string |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 406 | * @param int Item lifetime in seconds or 0 for default |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 407 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 408 | */ |
| 409 | public function set_tempdata($newdata = array(), $newval = '', $expire = 0) |
| 410 | { |
| 411 | // Set expiration time |
| 412 | $expire = time() + ($expire ? $expire : self::TEMP_EXP_DEF); |
| 413 | |
| 414 | // Wrap item as array if singular |
| 415 | if (is_string($newdata)) |
| 416 | { |
| 417 | $newdata = array($newdata => $newval); |
| 418 | } |
| 419 | |
| 420 | // Get or create expiration list |
| 421 | $expirations = $this->userdata(self::EXPIRATION_KEY); |
dchill42 | 77ee3fd | 2012-07-24 11:50:01 -0400 | [diff] [blame] | 422 | if ( ! $expirations) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 423 | { |
| 424 | $expirations = array(); |
| 425 | } |
| 426 | |
| 427 | // Prepend each key name and set value |
| 428 | if (count($newdata) > 0) |
| 429 | { |
| 430 | foreach ($newdata as $key => $val) |
| 431 | { |
| 432 | $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; |
| 433 | $expirations[$tempdata_key] = $expire; |
| 434 | $this->set_userdata($tempdata_key, $val); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | // Update expiration list |
| 439 | $this->set_userdata(self::EXPIRATION_KEY, $expirations); |
| 440 | } |
| 441 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 442 | // ------------------------------------------------------------------------ |
| 443 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 444 | /** |
| 445 | * Delete a temporary session variable from the "userdata" array |
| 446 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 447 | * @param mixed Item name or array of item names |
| 448 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 449 | */ |
| 450 | public function unset_tempdata($newdata = array()) |
| 451 | { |
| 452 | // Get expirations list |
| 453 | $expirations = $this->userdata(self::EXPIRATION_KEY); |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 454 | if (empty($expirations)) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 455 | { |
| 456 | // Nothing to do |
| 457 | return; |
| 458 | } |
| 459 | |
| 460 | // Wrap single name as array |
| 461 | if (is_string($newdata)) |
| 462 | { |
| 463 | $newdata = array($newdata => ''); |
| 464 | } |
| 465 | |
| 466 | // Prepend each item name and unset |
| 467 | if (count($newdata) > 0) |
| 468 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 469 | foreach (array_keys($newdata) as $key) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 470 | { |
| 471 | $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; |
| 472 | unset($expirations[$tempdata_key]); |
| 473 | $this->unset_userdata($tempdata_key); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | // Update expiration list |
| 478 | $this->set_userdata(self::EXPIRATION_KEY, $expirations); |
| 479 | } |
| 480 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 481 | // ------------------------------------------------------------------------ |
| 482 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 483 | /** |
| 484 | * Fetch a specific tempdata item from the session array |
| 485 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 486 | * @param string Item key |
| 487 | * @return string |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 488 | */ |
| 489 | public function tempdata($key) |
| 490 | { |
| 491 | // Prepend key and return value |
| 492 | $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key; |
| 493 | return $this->userdata($tempdata_key); |
| 494 | } |
| 495 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 496 | // ------------------------------------------------------------------------ |
| 497 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 498 | /** |
| 499 | * Identifies flashdata as 'old' for removal |
| 500 | * when _flashdata_sweep() runs. |
| 501 | * |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 502 | * @return void |
| 503 | */ |
Darren Hill | a2ae657 | 2011-09-01 07:36:26 -0400 | [diff] [blame] | 504 | protected function _flashdata_mark() |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 505 | { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 506 | foreach ($this->all_userdata() as $name => $value) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 507 | { |
| 508 | $parts = explode(self::FLASHDATA_NEW, $name); |
| 509 | if (is_array($parts) && count($parts) === 2) |
| 510 | { |
| 511 | $new_name = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$parts[1]; |
| 512 | $this->set_userdata($new_name, $value); |
| 513 | $this->unset_userdata($name); |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 518 | // ------------------------------------------------------------------------ |
| 519 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 520 | /** |
| 521 | * Removes all flashdata marked as 'old' |
| 522 | * |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 523 | * @return void |
| 524 | */ |
Darren Hill | a2ae657 | 2011-09-01 07:36:26 -0400 | [diff] [blame] | 525 | protected function _flashdata_sweep() |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 526 | { |
| 527 | $userdata = $this->all_userdata(); |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 528 | foreach (array_keys($userdata) as $key) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 529 | { |
| 530 | if (strpos($key, self::FLASHDATA_OLD)) |
| 531 | { |
| 532 | $this->unset_userdata($key); |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 537 | // ------------------------------------------------------------------------ |
| 538 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 539 | /** |
| 540 | * Removes all expired tempdata |
| 541 | * |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 542 | * @return void |
| 543 | */ |
Darren Hill | a2ae657 | 2011-09-01 07:36:26 -0400 | [diff] [blame] | 544 | protected function _tempdata_sweep() |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 545 | { |
| 546 | // Get expirations list |
| 547 | $expirations = $this->userdata(self::EXPIRATION_KEY); |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 548 | if (empty($expirations)) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 549 | { |
| 550 | // Nothing to do |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | // Unset expired elements |
| 555 | $now = time(); |
| 556 | $userdata = $this->all_userdata(); |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 557 | foreach (array_keys($userdata) as $key) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 558 | { |
| 559 | if (strpos($key, self::FLASHDATA_EXP) && $expirations[$key] < $now) |
| 560 | { |
| 561 | unset($expirations[$key]); |
| 562 | $this->unset_userdata($key); |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | // Update expiration list |
| 567 | $this->set_userdata(self::EXPIRATION_KEY, $expirations); |
| 568 | } |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 569 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | // ------------------------------------------------------------------------ |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 573 | |
| 574 | /** |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 575 | * CI_Session_driver Class |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 576 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 577 | * Extend this class to make a new CI_Session driver. |
| 578 | * A CI_Session driver basically manages an array of name/value pairs with some sort of storage mechanism. |
| 579 | * To make a new driver, derive from (extend) CI_Session_driver. Overload the initialize method and read or create |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 580 | * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler |
| 581 | * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata). |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 582 | * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the |
| 583 | * application directory, the system directory, or any path you add with $CI->load->add_package_path(). |
| 584 | * Your driver must be named CI_Session_<name>, and your filename must be Session_<name>.php, |
| 585 | * preferably also capitalized. (e.g.: CI_Session_foo in libraries/Session/drivers/Session_foo.php) |
| 586 | * Then specify the driver by setting 'sess_driver' in your config file or as a parameter when loading the CI_Session |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 587 | * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); ) |
| 588 | * Already provided are the Native driver, which manages the native PHP $_SESSION array, and |
| 589 | * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table. |
| 590 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 591 | * @package CodeIgniter |
| 592 | * @subpackage Libraries |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 593 | * @category Sessions |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 594 | * @author EllisLab Dev Team |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 595 | */ |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 596 | abstract class CI_Session_driver extends CI_Driver { |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 597 | |
Andrey Andreev | 2e3e230 | 2012-10-09 15:52:34 +0300 | [diff] [blame^] | 598 | protected $CI; |
| 599 | |
| 600 | /** |
| 601 | * Constructor |
| 602 | * |
| 603 | * Gets the CI singleton, so that individual drivers |
| 604 | * don't have to do it separately. |
| 605 | * |
| 606 | * @return void |
| 607 | */ |
| 608 | public function __construct() |
| 609 | { |
| 610 | $this->CI =& get_instance(); |
| 611 | } |
| 612 | |
| 613 | // ------------------------------------------------------------------------ |
| 614 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 615 | /** |
| 616 | * Decorate |
| 617 | * |
| 618 | * Decorates the child with the parent driver lib's methods and properties |
| 619 | * |
| 620 | * @param object Parent library object |
| 621 | * @return void |
| 622 | */ |
| 623 | public function decorate($parent) |
| 624 | { |
| 625 | // Call base class decorate first |
| 626 | parent::decorate($parent); |
| 627 | |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 628 | // Call initialize method now that driver has access to $this->_parent |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 629 | $this->initialize(); |
| 630 | } |
| 631 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 632 | // ------------------------------------------------------------------------ |
| 633 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 634 | /** |
| 635 | * __call magic method |
| 636 | * |
| 637 | * Handles access to the parent driver library's methods |
| 638 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 639 | * @param string Library method name |
| 640 | * @param array Method arguments (default: none) |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 641 | * @return mixed |
| 642 | */ |
| 643 | public function __call($method, $args = array()) |
| 644 | { |
| 645 | // Make sure the parent library uses this driver |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 646 | $this->_parent->select_driver(get_class($this)); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 647 | return parent::__call($method, $args); |
| 648 | } |
| 649 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 650 | // ------------------------------------------------------------------------ |
| 651 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 652 | /** |
| 653 | * Initialize driver |
| 654 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 655 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 656 | */ |
| 657 | protected function initialize() |
| 658 | { |
| 659 | // Overload this method to implement initialization |
| 660 | } |
| 661 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 662 | // ------------------------------------------------------------------------ |
| 663 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 664 | /** |
| 665 | * Save the session data |
| 666 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 667 | * Data in the array has changed - perform any storage synchronization |
| 668 | * necessary. The child class MUST implement this abstract method! |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 669 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 670 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 671 | */ |
| 672 | abstract public function sess_save(); |
| 673 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 674 | // ------------------------------------------------------------------------ |
| 675 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 676 | /** |
| 677 | * Destroy the current session |
| 678 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 679 | * Clean up storage for this session - it has been terminated. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 680 | * The child class MUST implement this abstract method! |
| 681 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 682 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 683 | */ |
| 684 | abstract public function sess_destroy(); |
| 685 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 686 | // ------------------------------------------------------------------------ |
| 687 | |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 688 | /** |
| 689 | * Regenerate the current session |
| 690 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 691 | * Regenerate the session ID. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 692 | * The child class MUST implement this abstract method! |
| 693 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 694 | * @param bool Destroy session data flag (default: false) |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 695 | * @return void |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 696 | */ |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 697 | abstract public function sess_regenerate($destroy = FALSE); |
| 698 | |
| 699 | // ------------------------------------------------------------------------ |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 700 | |
| 701 | /** |
| 702 | * Get a reference to user data array |
| 703 | * |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 704 | * Give array access to the main CI_Session object. |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 705 | * The child class MUST implement this abstract method! |
| 706 | * |
Darren Hill | 5073a37 | 2011-08-31 13:54:19 -0400 | [diff] [blame] | 707 | * @return array Reference to userdata |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 708 | */ |
| 709 | abstract public function &get_userdata(); |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 710 | |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 711 | } |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 712 | |
| 713 | /* End of file Session.php */ |
Andrey Andreev | 9ffcee6 | 2012-09-05 16:25:16 +0300 | [diff] [blame] | 714 | /* Location: ./system/libraries/Session/Session.php */ |