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