blob: 97eab803fa5b5b4b2f5aadf5ea6e7a8e773725db [file] [log] [blame]
Darren Hillc4e266b2011-08-30 15:40:27 -04001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 2.0
13 * @filesource
14 */
15
16
17/**
Darren Hill5073a372011-08-31 13:54:19 -040018 * CI_Session Class
Darren Hillc4e266b2011-08-30 15:40:27 -040019 *
20 * The user interface defined by EllisLabs, now with puggable drivers to manage different storage mechanisms.
dchill420e884082012-08-11 20:10:17 -040021 * By default, the cookie session driver will load, but the 'sess_driver' config/param item (see above) can be
22 * used to specify the 'native' driver, or any other you might create.
Darren Hillc4e266b2011-08-30 15:40:27 -040023 * Once loaded, this driver setup is a drop-in replacement for the former CI_Session library, taking its place as the
24 * 'session' member of the global controller framework (e.g.: $CI->session or $this->session).
25 * In keeping with the CI_Driver methodology, multiple drivers may be loaded, although this might be a bit confusing.
Darren Hill5073a372011-08-31 13:54:19 -040026 * The CI_Session library class keeps track of the most recently loaded driver as "current" to call for driver methods.
Darren Hillc4e266b2011-08-30 15:40:27 -040027 * Ideally, one driver is loaded and all calls go directly through the main library interface. However, any methods
28 * called through the specific driver will switch the "current" driver to itself before invoking the library method
29 * (which will then call back into the driver for low-level operations). So, alternation between two drivers can be
30 * achieved by specifying which driver to use for each call (e.g.: $this->session->native->set_userdata('foo', 'bar');
31 * $this->session->cookie->userdata('foo'); $this->session->native->unset_userdata('foo');). Notice in the previous
32 * example that the _native_ userdata value 'foo' would be set to 'bar', which would NOT be returned by the call for
33 * the _cookie_ userdata 'foo', nor would the _cookie_ value be unset by the call to unset the _native_ 'foo' value.
34 *
35 * @package CodeIgniter
36 * @subpackage Libraries
37 * @category Sessions
Darren Hill5073a372011-08-31 13:54:19 -040038 * @author ExpressionEngine Dev Team
Darren Hillc4e266b2011-08-30 15:40:27 -040039 * @link http://codeigniter.com/user_guide/libraries/sessions.html
40 */
Darren Hilla2ae6572011-09-01 07:36:26 -040041class CI_Session extends CI_Driver_Library {
Darren Hillc4e266b2011-08-30 15:40:27 -040042 public $params = array();
Darren Hilla2ae6572011-09-01 07:36:26 -040043 protected $current = null;
44 protected $userdata = array();
Darren Hillc4e266b2011-08-30 15:40:27 -040045
46 const FLASHDATA_KEY = 'flash';
47 const FLASHDATA_NEW = ':new:';
48 const FLASHDATA_OLD = ':old:';
49 const FLASHDATA_EXP = ':exp:';
50 const EXPIRATION_KEY = '__expirations';
51 const TEMP_EXP_DEF = 300;
52
53 /**
Darren Hill5073a372011-08-31 13:54:19 -040054 * CI_Session constructor
Darren Hillc4e266b2011-08-30 15:40:27 -040055 *
56 * The constructor loads the configured driver ('sess_driver' in config.php or as a parameter), running
57 * routines in its constructor, and manages flashdata aging.
58 *
Darren Hill5073a372011-08-31 13:54:19 -040059 * @param array Configuration parameters
Darren Hillc4e266b2011-08-30 15:40:27 -040060 */
61 public function __construct(array $params = array())
62 {
Darren Hill5073a372011-08-31 13:54:19 -040063 log_message('debug', 'CI_Session Class Initialized');
Darren Hillc4e266b2011-08-30 15:40:27 -040064
65 // Get valid drivers list
66 $CI =& get_instance();
dchill4226429202012-07-31 10:55:07 -040067 $this->valid_drivers = array(
68 'Session_native',
69 'Session_cookie'
70 );
Darren Hillc4e266b2011-08-30 15:40:27 -040071 $key = 'sess_valid_drivers';
72 $drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
73 if ($drivers)
74 {
dchill4277ee3fd2012-07-24 11:50:01 -040075 if ( ! is_array($drivers)) $drivers = array($drivers);
Darren Hillc4e266b2011-08-30 15:40:27 -040076
77 // Add driver names to valid list
78 foreach ($drivers as $driver)
79 {
dchill4277ee3fd2012-07-24 11:50:01 -040080 if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers)))
Darren Hillc4e266b2011-08-30 15:40:27 -040081 {
82 $this->valid_drivers[] = $driver;
83 }
84 }
85 }
86
87 // Get driver to load
88 $key = 'sess_driver';
89 $driver = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
dchill4277ee3fd2012-07-24 11:50:01 -040090 if ( ! $driver) $driver = 'cookie';
91 if ( ! in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers)))
Darren Hillc4e266b2011-08-30 15:40:27 -040092 {
93 $this->valid_drivers[] = 'Session_'.$driver;
94 }
95
96 // Save a copy of parameters in case drivers need access
97 $this->params = $params;
98
99 // Load driver and get array reference
100 $this->load_driver($driver);
Darren Hillc4e266b2011-08-30 15:40:27 -0400101
102 // Delete 'old' flashdata (from last request)
103 $this->_flashdata_sweep();
104
105 // Mark all new flashdata as old (data will be deleted before next request)
106 $this->_flashdata_mark();
107
108 // Delete expired tempdata
109 $this->_tempdata_sweep();
110
Darren Hill5073a372011-08-31 13:54:19 -0400111 log_message('debug', 'CI_Session routines successfully run');
Darren Hillc4e266b2011-08-30 15:40:27 -0400112 }
113
114 /**
115 * Loads session storage driver
116 *
Darren Hill5073a372011-08-31 13:54:19 -0400117 * @param string Driver classname
118 * @return object Loaded driver object
Darren Hillc4e266b2011-08-30 15:40:27 -0400119 */
120 public function load_driver($driver)
121 {
dchill4226429202012-07-31 10:55:07 -0400122 // Save reference to most recently loaded driver as library default and sync userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400123 $this->current = parent::load_driver($driver);
dchill42b1855372012-07-31 09:32:23 -0400124 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400125 return $this->current;
126 }
127
128 /**
129 * Select default session storage driver
130 *
Darren Hill5073a372011-08-31 13:54:19 -0400131 * @param string Driver classname
132 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400133 */
134 public function select_driver($driver)
135 {
136 // Validate driver name
dchill42c5872252012-07-30 14:53:11 -0400137 $lowername = strtolower(str_replace('CI_', '', $driver));
Darren Hillc4e266b2011-08-30 15:40:27 -0400138 if (in_array($lowername, array_map('strtolower', $this->valid_drivers)))
139 {
dchill42b1855372012-07-31 09:32:23 -0400140 // See if driver is loaded
141 $child = str_replace($this->lib_name.'_', '', $driver);
142 if (isset($this->$child))
Darren Hillc4e266b2011-08-30 15:40:27 -0400143 {
dchill4226429202012-07-31 10:55:07 -0400144 // Make driver current and sync userdata
dchill42b1855372012-07-31 09:32:23 -0400145 $this->current = $this->$child;
dchill4226429202012-07-31 10:55:07 -0400146 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400147 }
148 else
149 {
dchill4226429202012-07-31 10:55:07 -0400150 // Load new driver
Darren Hillc4e266b2011-08-30 15:40:27 -0400151 $this->load_driver($driver);
152 }
153 }
154 }
155
156 /**
157 * Destroy the current session
158 *
Darren Hill5073a372011-08-31 13:54:19 -0400159 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400160 */
161 public function sess_destroy()
162 {
163 // Just call destroy on driver
164 $this->current->sess_destroy();
165 }
166
167 /**
168 * Regenerate the current session
169 *
Darren Hill5073a372011-08-31 13:54:19 -0400170 * @param boolean Destroy session data flag (default: false)
171 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400172 */
173 public function sess_regenerate($destroy = false)
174 {
dchill4226429202012-07-31 10:55:07 -0400175 // Call regenerate on driver and resync userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400176 $this->current->sess_regenerate($destroy);
dchill4226429202012-07-31 10:55:07 -0400177 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400178 }
179
180 /**
181 * Fetch a specific item from the session array
182 *
Darren Hill5073a372011-08-31 13:54:19 -0400183 * @param string Item key
dchill42c5872252012-07-30 14:53:11 -0400184 * @return string Item value or NULL if not found
Darren Hillc4e266b2011-08-30 15:40:27 -0400185 */
186 public function userdata($item)
187 {
dchill42c5872252012-07-30 14:53:11 -0400188 // Return value or NULL if not found
dchill4277ee3fd2012-07-24 11:50:01 -0400189 return ( ! isset($this->userdata[$item])) ? NULL : $this->userdata[$item];
Darren Hillc4e266b2011-08-30 15:40:27 -0400190 }
191
192 /**
193 * Fetch all session data
194 *
195 * @return array User data array
196 */
197 public function all_userdata()
198 {
199 // Return entire array
dchill4277ee3fd2012-07-24 11:50:01 -0400200 return ( ! isset($this->userdata)) ? NULL : $this->userdata;
Darren Hillc4e266b2011-08-30 15:40:27 -0400201 }
202
203 /**
dchill42c5079de2012-07-23 10:53:47 -0400204 * Fetch all flashdata
205 *
206 * @return array Flash data array
207 */
208 public function all_flashdata()
209 {
210 $out = array();
211
212 // loop through all userdata
213 foreach ($this->all_userdata() as $key => $val)
214 {
dchill42c5872252012-07-30 14:53:11 -0400215 // if it contains flashdata, add it
dchill42c5079de2012-07-23 10:53:47 -0400216 if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE)
217 {
dchill4226429202012-07-31 10:55:07 -0400218 $key = str_replace(self::FLASHDATA_KEY.self::FLASHDATA_OLD, '', $key);
dchill42c5079de2012-07-23 10:53:47 -0400219 $out[$key] = $val;
220 }
221 }
222 return $out;
223 }
224
225 /**
Darren Hillc4e266b2011-08-30 15:40:27 -0400226 * Add or change data in the "userdata" array
227 *
Darren Hill5073a372011-08-31 13:54:19 -0400228 * @param mixed Item name or array of items
229 * @param string Item value or empty string
230 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400231 */
232 public function set_userdata($newdata = array(), $newval = '')
233 {
234 // Wrap params as array if singular
235 if (is_string($newdata))
236 {
237 $newdata = array($newdata => $newval);
238 }
239
240 // Set each name/value pair
241 if (count($newdata) > 0)
242 {
243 foreach ($newdata as $key => $val)
244 {
245 $this->userdata[$key] = $val;
246 }
247 }
248
249 // Tell driver data changed
250 $this->current->sess_save();
251 }
252
253 /**
254 * Delete a session variable from the "userdata" array
255 *
Darren Hill5073a372011-08-31 13:54:19 -0400256 * @param mixed Item name or array of item names
257 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400258 */
259 public function unset_userdata($newdata = array())
260 {
261 // Wrap single name as array
262 if (is_string($newdata))
263 {
264 $newdata = array($newdata => '');
265 }
266
267 // Unset each item name
268 if (count($newdata) > 0)
269 {
270 foreach ($newdata as $key => $val)
271 {
272 unset($this->userdata[$key]);
273 }
274 }
275
276 // Tell driver data changed
277 $this->current->sess_save();
278 }
279
280 /**
281 * Determine if an item exists
282 *
Darren Hill5073a372011-08-31 13:54:19 -0400283 * @param string Item name
284 * @return boolean
Darren Hillc4e266b2011-08-30 15:40:27 -0400285 */
286 public function has_userdata($item)
287 {
288 // Check for item name
289 return isset($this->userdata[$item]);
290 }
291
292 /**
293 * Add or change flashdata, only available until the next request
294 *
Darren Hill5073a372011-08-31 13:54:19 -0400295 * @param mixed Item name or array of items
296 * @param string Item value or empty string
297 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400298 */
299 public function set_flashdata($newdata = array(), $newval = '')
300 {
301 // Wrap item as array if singular
302 if (is_string($newdata))
303 {
304 $newdata = array($newdata => $newval);
305 }
306
307 // Prepend each key name and set value
308 if (count($newdata) > 0)
309 {
310 foreach ($newdata as $key => $val)
311 {
312 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
313 $this->set_userdata($flashdata_key, $val);
314 }
315 }
316 }
317
318 /**
319 * Keeps existing flashdata available to next request.
320 *
Darren Hill5073a372011-08-31 13:54:19 -0400321 * @param string Item key
322 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400323 */
324 public function keep_flashdata($key)
325 {
dchill42c5079de2012-07-23 10:53:47 -0400326 // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep()
327 // Note the function will return NULL if the $key provided cannot be found
Darren Hillc4e266b2011-08-30 15:40:27 -0400328 $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
329 $value = $this->userdata($old_flashdata_key);
330
331 $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
332 $this->set_userdata($new_flashdata_key, $value);
333 }
334
335 /**
336 * Fetch a specific flashdata item from the session array
337 *
Darren Hill5073a372011-08-31 13:54:19 -0400338 * @param string Item key
339 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400340 */
341 public function flashdata($key)
342 {
343 // Prepend key and retrieve value
344 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
345 return $this->userdata($flashdata_key);
346 }
347
348 /**
349 * Add or change tempdata, only available
350 * until expiration
351 *
Darren Hill5073a372011-08-31 13:54:19 -0400352 * @param mixed Item name or array of items
353 * @param string Item value or empty string
354 * @param int Item lifetime in seconds or 0 for default
355 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400356 */
357 public function set_tempdata($newdata = array(), $newval = '', $expire = 0)
358 {
359 // Set expiration time
360 $expire = time() + ($expire ? $expire : self::TEMP_EXP_DEF);
361
362 // Wrap item as array if singular
363 if (is_string($newdata))
364 {
365 $newdata = array($newdata => $newval);
366 }
367
368 // Get or create expiration list
369 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400370 if ( ! $expirations)
Darren Hillc4e266b2011-08-30 15:40:27 -0400371 {
372 $expirations = array();
373 }
374
375 // Prepend each key name and set value
376 if (count($newdata) > 0)
377 {
378 foreach ($newdata as $key => $val)
379 {
380 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
381 $expirations[$tempdata_key] = $expire;
382 $this->set_userdata($tempdata_key, $val);
383 }
384 }
385
386 // Update expiration list
387 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
388 }
389
390 /**
391 * Delete a temporary session variable from the "userdata" array
392 *
Darren Hill5073a372011-08-31 13:54:19 -0400393 * @param mixed Item name or array of item names
394 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400395 */
396 public function unset_tempdata($newdata = array())
397 {
398 // Get expirations list
399 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400400 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400401 {
402 // Nothing to do
403 return;
404 }
405
406 // Wrap single name as array
407 if (is_string($newdata))
408 {
409 $newdata = array($newdata => '');
410 }
411
412 // Prepend each item name and unset
413 if (count($newdata) > 0)
414 {
415 foreach ($newdata as $key => $val)
416 {
417 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
418 unset($expirations[$tempdata_key]);
419 $this->unset_userdata($tempdata_key);
420 }
421 }
422
423 // Update expiration list
424 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
425 }
426
427 /**
428 * Fetch a specific tempdata item from the session array
429 *
Darren Hill5073a372011-08-31 13:54:19 -0400430 * @param string Item key
431 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400432 */
433 public function tempdata($key)
434 {
435 // Prepend key and return value
436 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
437 return $this->userdata($tempdata_key);
438 }
439
440 /**
441 * Identifies flashdata as 'old' for removal
442 * when _flashdata_sweep() runs.
443 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400444 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400445 * @return void
446 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400447 protected function _flashdata_mark()
Darren Hillc4e266b2011-08-30 15:40:27 -0400448 {
449 $userdata = $this->all_userdata();
450 foreach ($userdata as $name => $value)
451 {
452 $parts = explode(self::FLASHDATA_NEW, $name);
453 if (is_array($parts) && count($parts) === 2)
454 {
455 $new_name = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$parts[1];
456 $this->set_userdata($new_name, $value);
457 $this->unset_userdata($name);
458 }
459 }
460 }
461
462 /**
463 * Removes all flashdata marked as 'old'
464 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400465 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400466 * @return void
467 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400468 protected function _flashdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400469 {
470 $userdata = $this->all_userdata();
471 foreach ($userdata as $key => $value)
472 {
473 if (strpos($key, self::FLASHDATA_OLD))
474 {
475 $this->unset_userdata($key);
476 }
477 }
478 }
479
480 /**
481 * Removes all expired tempdata
482 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400483 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400484 * @return void
485 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400486 protected function _tempdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400487 {
488 // Get expirations list
489 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400490 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400491 {
492 // Nothing to do
493 return;
494 }
495
496 // Unset expired elements
497 $now = time();
498 $userdata = $this->all_userdata();
499 foreach ($userdata as $key => $value)
500 {
501 if (strpos($key, self::FLASHDATA_EXP) && $expirations[$key] < $now)
502 {
503 unset($expirations[$key]);
504 $this->unset_userdata($key);
505 }
506 }
507
508 // Update expiration list
509 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
510 }
511}
Darren Hill5073a372011-08-31 13:54:19 -0400512// END CI_Session Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400513
514
515/**
Darren Hill5073a372011-08-31 13:54:19 -0400516 * CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400517 *
Darren Hill5073a372011-08-31 13:54:19 -0400518 * Extend this class to make a new CI_Session driver.
519 * A CI_Session driver basically manages an array of name/value pairs with some sort of storage mechanism.
520 * To make a new driver, derive from (extend) CI_Session_driver. Overload the initialize method and read or create
Darren Hillc4e266b2011-08-30 15:40:27 -0400521 * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler
522 * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata).
Darren Hill5073a372011-08-31 13:54:19 -0400523 * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the
524 * application directory, the system directory, or any path you add with $CI->load->add_package_path().
525 * Your driver must be named CI_Session_<name>, and your filename must be Session_<name>.php,
526 * preferably also capitalized. (e.g.: CI_Session_foo in libraries/Session/drivers/Session_foo.php)
527 * Then specify the driver by setting 'sess_driver' in your config file or as a parameter when loading the CI_Session
Darren Hillc4e266b2011-08-30 15:40:27 -0400528 * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); )
529 * Already provided are the Native driver, which manages the native PHP $_SESSION array, and
530 * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table.
531 *
Darren Hill5073a372011-08-31 13:54:19 -0400532 * @package CodeIgniter
533 * @subpackage Libraries
Darren Hillc4e266b2011-08-30 15:40:27 -0400534 * @category Sessions
Darren Hill5073a372011-08-31 13:54:19 -0400535 * @author ExpressionEngine Dev Team
Darren Hillc4e266b2011-08-30 15:40:27 -0400536 */
Darren Hill5073a372011-08-31 13:54:19 -0400537abstract class CI_Session_driver extends CI_Driver {
Darren Hillc4e266b2011-08-30 15:40:27 -0400538 /**
539 * Decorate
540 *
541 * Decorates the child with the parent driver lib's methods and properties
542 *
543 * @param object Parent library object
544 * @return void
545 */
546 public function decorate($parent)
547 {
548 // Call base class decorate first
549 parent::decorate($parent);
550
dchill42c5872252012-07-30 14:53:11 -0400551 // Call initialize method now that driver has access to $this->_parent
Darren Hillc4e266b2011-08-30 15:40:27 -0400552 $this->initialize();
553 }
554
555 /**
556 * __call magic method
557 *
558 * Handles access to the parent driver library's methods
559 *
Darren Hill5073a372011-08-31 13:54:19 -0400560 * @param string Library method name
561 * @param array Method arguments (default: none)
Darren Hillc4e266b2011-08-30 15:40:27 -0400562 * @return mixed
563 */
564 public function __call($method, $args = array())
565 {
566 // Make sure the parent library uses this driver
dchill42c5872252012-07-30 14:53:11 -0400567 $this->_parent->select_driver(get_class($this));
Darren Hillc4e266b2011-08-30 15:40:27 -0400568 return parent::__call($method, $args);
569 }
570
571 /**
572 * Initialize driver
573 *
Darren Hill5073a372011-08-31 13:54:19 -0400574 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400575 */
576 protected function initialize()
577 {
578 // Overload this method to implement initialization
579 }
580
581 /**
582 * Save the session data
583 *
584 * Data in the array has changed - perform any storage synchronization necessary
585 * The child class MUST implement this abstract method!
586 *
Darren Hill5073a372011-08-31 13:54:19 -0400587 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400588 */
589 abstract public function sess_save();
590
591 /**
592 * Destroy the current session
593 *
594 * Clean up storage for this session - it has been terminated
595 * The child class MUST implement this abstract method!
596 *
Darren Hill5073a372011-08-31 13:54:19 -0400597 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400598 */
599 abstract public function sess_destroy();
600
601 /**
602 * Regenerate the current session
603 *
604 * Regenerate the session id
605 * The child class MUST implement this abstract method!
606 *
Darren Hill5073a372011-08-31 13:54:19 -0400607 * @param boolean Destroy session data flag (default: false)
608 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400609 */
610 abstract public function sess_regenerate($destroy = false);
611
612 /**
613 * Get a reference to user data array
614 *
Darren Hill5073a372011-08-31 13:54:19 -0400615 * Give array access to the main CI_Session object
Darren Hillc4e266b2011-08-30 15:40:27 -0400616 * The child class MUST implement this abstract method!
617 *
Darren Hill5073a372011-08-31 13:54:19 -0400618 * @return array Reference to userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400619 */
620 abstract public function &get_userdata();
621}
Darren Hill5073a372011-08-31 13:54:19 -0400622// END CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400623
624
625/* End of file Session.php */
626/* Location: ./system/libraries/Session/Session.php */
627?>