blob: 1f24456a40e47b0c2d953b80d8b9ad212453ea7e [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 {
dchill42aee92652012-08-26 21:45:35 -0400144 // See if driver is already current
145 if ($this->$child !== $this->current) {
146 // Make driver current and sync userdata
147 $this->current = $this->$child;
148 $this->userdata =& $this->current->get_userdata();
149 }
Darren Hillc4e266b2011-08-30 15:40:27 -0400150 }
151 else
152 {
dchill4226429202012-07-31 10:55:07 -0400153 // Load new driver
dchill42aee92652012-08-26 21:45:35 -0400154 $this->load_driver($child);
Darren Hillc4e266b2011-08-30 15:40:27 -0400155 }
156 }
157 }
158
159 /**
160 * Destroy the current session
161 *
Darren Hill5073a372011-08-31 13:54:19 -0400162 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400163 */
164 public function sess_destroy()
165 {
166 // Just call destroy on driver
167 $this->current->sess_destroy();
168 }
169
170 /**
171 * Regenerate the current session
172 *
Darren Hill5073a372011-08-31 13:54:19 -0400173 * @param boolean Destroy session data flag (default: false)
174 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400175 */
176 public function sess_regenerate($destroy = false)
177 {
dchill4226429202012-07-31 10:55:07 -0400178 // Call regenerate on driver and resync userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400179 $this->current->sess_regenerate($destroy);
dchill4226429202012-07-31 10:55:07 -0400180 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400181 }
182
183 /**
184 * Fetch a specific item from the session array
185 *
Darren Hill5073a372011-08-31 13:54:19 -0400186 * @param string Item key
dchill42c5872252012-07-30 14:53:11 -0400187 * @return string Item value or NULL if not found
Darren Hillc4e266b2011-08-30 15:40:27 -0400188 */
189 public function userdata($item)
190 {
dchill42c5872252012-07-30 14:53:11 -0400191 // Return value or NULL if not found
dchill4277ee3fd2012-07-24 11:50:01 -0400192 return ( ! isset($this->userdata[$item])) ? NULL : $this->userdata[$item];
Darren Hillc4e266b2011-08-30 15:40:27 -0400193 }
194
195 /**
196 * Fetch all session data
197 *
198 * @return array User data array
199 */
200 public function all_userdata()
201 {
202 // Return entire array
dchill4277ee3fd2012-07-24 11:50:01 -0400203 return ( ! isset($this->userdata)) ? NULL : $this->userdata;
Darren Hillc4e266b2011-08-30 15:40:27 -0400204 }
205
206 /**
dchill42c5079de2012-07-23 10:53:47 -0400207 * Fetch all flashdata
208 *
209 * @return array Flash data array
210 */
211 public function all_flashdata()
212 {
213 $out = array();
214
215 // loop through all userdata
216 foreach ($this->all_userdata() as $key => $val)
217 {
dchill42c5872252012-07-30 14:53:11 -0400218 // if it contains flashdata, add it
dchill42c5079de2012-07-23 10:53:47 -0400219 if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE)
220 {
dchill4226429202012-07-31 10:55:07 -0400221 $key = str_replace(self::FLASHDATA_KEY.self::FLASHDATA_OLD, '', $key);
dchill42c5079de2012-07-23 10:53:47 -0400222 $out[$key] = $val;
223 }
224 }
225 return $out;
226 }
227
228 /**
Darren Hillc4e266b2011-08-30 15:40:27 -0400229 * Add or change data in the "userdata" array
230 *
Darren Hill5073a372011-08-31 13:54:19 -0400231 * @param mixed Item name or array of items
232 * @param string Item value or empty string
233 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400234 */
235 public function set_userdata($newdata = array(), $newval = '')
236 {
237 // Wrap params as array if singular
238 if (is_string($newdata))
239 {
240 $newdata = array($newdata => $newval);
241 }
242
243 // Set each name/value pair
244 if (count($newdata) > 0)
245 {
246 foreach ($newdata as $key => $val)
247 {
248 $this->userdata[$key] = $val;
249 }
250 }
251
252 // Tell driver data changed
253 $this->current->sess_save();
254 }
255
256 /**
257 * Delete a session variable from the "userdata" array
258 *
Darren Hill5073a372011-08-31 13:54:19 -0400259 * @param mixed Item name or array of item names
260 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400261 */
262 public function unset_userdata($newdata = array())
263 {
264 // Wrap single name as array
265 if (is_string($newdata))
266 {
267 $newdata = array($newdata => '');
268 }
269
270 // Unset each item name
271 if (count($newdata) > 0)
272 {
273 foreach ($newdata as $key => $val)
274 {
275 unset($this->userdata[$key]);
276 }
277 }
278
279 // Tell driver data changed
280 $this->current->sess_save();
281 }
282
283 /**
284 * Determine if an item exists
285 *
Darren Hill5073a372011-08-31 13:54:19 -0400286 * @param string Item name
287 * @return boolean
Darren Hillc4e266b2011-08-30 15:40:27 -0400288 */
289 public function has_userdata($item)
290 {
291 // Check for item name
292 return isset($this->userdata[$item]);
293 }
294
295 /**
296 * Add or change flashdata, only available until the next request
297 *
Darren Hill5073a372011-08-31 13:54:19 -0400298 * @param mixed Item name or array of items
299 * @param string Item value or empty string
300 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400301 */
302 public function set_flashdata($newdata = array(), $newval = '')
303 {
304 // Wrap item as array if singular
305 if (is_string($newdata))
306 {
307 $newdata = array($newdata => $newval);
308 }
309
310 // Prepend each key name and set value
311 if (count($newdata) > 0)
312 {
313 foreach ($newdata as $key => $val)
314 {
315 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
316 $this->set_userdata($flashdata_key, $val);
317 }
318 }
319 }
320
321 /**
322 * Keeps existing flashdata available to next request.
323 *
Darren Hill5073a372011-08-31 13:54:19 -0400324 * @param string Item key
325 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400326 */
327 public function keep_flashdata($key)
328 {
dchill42c5079de2012-07-23 10:53:47 -0400329 // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep()
330 // Note the function will return NULL if the $key provided cannot be found
Darren Hillc4e266b2011-08-30 15:40:27 -0400331 $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
332 $value = $this->userdata($old_flashdata_key);
333
334 $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
335 $this->set_userdata($new_flashdata_key, $value);
336 }
337
338 /**
339 * Fetch a specific flashdata item from the session array
340 *
Darren Hill5073a372011-08-31 13:54:19 -0400341 * @param string Item key
342 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400343 */
344 public function flashdata($key)
345 {
346 // Prepend key and retrieve value
347 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
348 return $this->userdata($flashdata_key);
349 }
350
351 /**
352 * Add or change tempdata, only available
353 * until expiration
354 *
Darren Hill5073a372011-08-31 13:54:19 -0400355 * @param mixed Item name or array of items
356 * @param string Item value or empty string
357 * @param int Item lifetime in seconds or 0 for default
358 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400359 */
360 public function set_tempdata($newdata = array(), $newval = '', $expire = 0)
361 {
362 // Set expiration time
363 $expire = time() + ($expire ? $expire : self::TEMP_EXP_DEF);
364
365 // Wrap item as array if singular
366 if (is_string($newdata))
367 {
368 $newdata = array($newdata => $newval);
369 }
370
371 // Get or create expiration list
372 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400373 if ( ! $expirations)
Darren Hillc4e266b2011-08-30 15:40:27 -0400374 {
375 $expirations = array();
376 }
377
378 // Prepend each key name and set value
379 if (count($newdata) > 0)
380 {
381 foreach ($newdata as $key => $val)
382 {
383 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
384 $expirations[$tempdata_key] = $expire;
385 $this->set_userdata($tempdata_key, $val);
386 }
387 }
388
389 // Update expiration list
390 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
391 }
392
393 /**
394 * Delete a temporary session variable from the "userdata" array
395 *
Darren Hill5073a372011-08-31 13:54:19 -0400396 * @param mixed Item name or array of item names
397 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400398 */
399 public function unset_tempdata($newdata = array())
400 {
401 // Get expirations list
402 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400403 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400404 {
405 // Nothing to do
406 return;
407 }
408
409 // Wrap single name as array
410 if (is_string($newdata))
411 {
412 $newdata = array($newdata => '');
413 }
414
415 // Prepend each item name and unset
416 if (count($newdata) > 0)
417 {
418 foreach ($newdata as $key => $val)
419 {
420 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
421 unset($expirations[$tempdata_key]);
422 $this->unset_userdata($tempdata_key);
423 }
424 }
425
426 // Update expiration list
427 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
428 }
429
430 /**
431 * Fetch a specific tempdata item from the session array
432 *
Darren Hill5073a372011-08-31 13:54:19 -0400433 * @param string Item key
434 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400435 */
436 public function tempdata($key)
437 {
438 // Prepend key and return value
439 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
440 return $this->userdata($tempdata_key);
441 }
442
443 /**
444 * Identifies flashdata as 'old' for removal
445 * when _flashdata_sweep() runs.
446 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400447 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400448 * @return void
449 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400450 protected function _flashdata_mark()
Darren Hillc4e266b2011-08-30 15:40:27 -0400451 {
452 $userdata = $this->all_userdata();
453 foreach ($userdata as $name => $value)
454 {
455 $parts = explode(self::FLASHDATA_NEW, $name);
456 if (is_array($parts) && count($parts) === 2)
457 {
458 $new_name = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$parts[1];
459 $this->set_userdata($new_name, $value);
460 $this->unset_userdata($name);
461 }
462 }
463 }
464
465 /**
466 * Removes all flashdata marked as 'old'
467 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400468 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400469 * @return void
470 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400471 protected function _flashdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400472 {
473 $userdata = $this->all_userdata();
474 foreach ($userdata as $key => $value)
475 {
476 if (strpos($key, self::FLASHDATA_OLD))
477 {
478 $this->unset_userdata($key);
479 }
480 }
481 }
482
483 /**
484 * Removes all expired tempdata
485 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400486 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400487 * @return void
488 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400489 protected function _tempdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400490 {
491 // Get expirations list
492 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400493 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400494 {
495 // Nothing to do
496 return;
497 }
498
499 // Unset expired elements
500 $now = time();
501 $userdata = $this->all_userdata();
502 foreach ($userdata as $key => $value)
503 {
504 if (strpos($key, self::FLASHDATA_EXP) && $expirations[$key] < $now)
505 {
506 unset($expirations[$key]);
507 $this->unset_userdata($key);
508 }
509 }
510
511 // Update expiration list
512 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
513 }
514}
Darren Hill5073a372011-08-31 13:54:19 -0400515// END CI_Session Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400516
517
518/**
Darren Hill5073a372011-08-31 13:54:19 -0400519 * CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400520 *
Darren Hill5073a372011-08-31 13:54:19 -0400521 * Extend this class to make a new CI_Session driver.
522 * A CI_Session driver basically manages an array of name/value pairs with some sort of storage mechanism.
523 * 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 -0400524 * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler
525 * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata).
Darren Hill5073a372011-08-31 13:54:19 -0400526 * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the
527 * application directory, the system directory, or any path you add with $CI->load->add_package_path().
528 * Your driver must be named CI_Session_<name>, and your filename must be Session_<name>.php,
529 * preferably also capitalized. (e.g.: CI_Session_foo in libraries/Session/drivers/Session_foo.php)
530 * 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 -0400531 * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); )
532 * Already provided are the Native driver, which manages the native PHP $_SESSION array, and
533 * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table.
534 *
Darren Hill5073a372011-08-31 13:54:19 -0400535 * @package CodeIgniter
536 * @subpackage Libraries
Darren Hillc4e266b2011-08-30 15:40:27 -0400537 * @category Sessions
Darren Hill5073a372011-08-31 13:54:19 -0400538 * @author ExpressionEngine Dev Team
Darren Hillc4e266b2011-08-30 15:40:27 -0400539 */
Darren Hill5073a372011-08-31 13:54:19 -0400540abstract class CI_Session_driver extends CI_Driver {
Darren Hillc4e266b2011-08-30 15:40:27 -0400541 /**
542 * Decorate
543 *
544 * Decorates the child with the parent driver lib's methods and properties
545 *
546 * @param object Parent library object
547 * @return void
548 */
549 public function decorate($parent)
550 {
551 // Call base class decorate first
552 parent::decorate($parent);
553
dchill42c5872252012-07-30 14:53:11 -0400554 // Call initialize method now that driver has access to $this->_parent
Darren Hillc4e266b2011-08-30 15:40:27 -0400555 $this->initialize();
556 }
557
558 /**
559 * __call magic method
560 *
561 * Handles access to the parent driver library's methods
562 *
Darren Hill5073a372011-08-31 13:54:19 -0400563 * @param string Library method name
564 * @param array Method arguments (default: none)
Darren Hillc4e266b2011-08-30 15:40:27 -0400565 * @return mixed
566 */
567 public function __call($method, $args = array())
568 {
569 // Make sure the parent library uses this driver
dchill42c5872252012-07-30 14:53:11 -0400570 $this->_parent->select_driver(get_class($this));
Darren Hillc4e266b2011-08-30 15:40:27 -0400571 return parent::__call($method, $args);
572 }
573
574 /**
575 * Initialize driver
576 *
Darren Hill5073a372011-08-31 13:54:19 -0400577 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400578 */
579 protected function initialize()
580 {
581 // Overload this method to implement initialization
582 }
583
584 /**
585 * Save the session data
586 *
587 * Data in the array has changed - perform any storage synchronization necessary
588 * The child class MUST implement this abstract method!
589 *
Darren Hill5073a372011-08-31 13:54:19 -0400590 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400591 */
592 abstract public function sess_save();
593
594 /**
595 * Destroy the current session
596 *
597 * Clean up storage for this session - it has been terminated
598 * The child class MUST implement this abstract method!
599 *
Darren Hill5073a372011-08-31 13:54:19 -0400600 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400601 */
602 abstract public function sess_destroy();
603
604 /**
605 * Regenerate the current session
606 *
607 * Regenerate the session id
608 * The child class MUST implement this abstract method!
609 *
Darren Hill5073a372011-08-31 13:54:19 -0400610 * @param boolean Destroy session data flag (default: false)
611 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400612 */
613 abstract public function sess_regenerate($destroy = false);
614
615 /**
616 * Get a reference to user data array
617 *
Darren Hill5073a372011-08-31 13:54:19 -0400618 * Give array access to the main CI_Session object
Darren Hillc4e266b2011-08-30 15:40:27 -0400619 * The child class MUST implement this abstract method!
620 *
Darren Hill5073a372011-08-31 13:54:19 -0400621 * @return array Reference to userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400622 */
623 abstract public function &get_userdata();
624}
Darren Hill5073a372011-08-31 13:54:19 -0400625// END CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400626
627
628/* End of file Session.php */
629/* Location: ./system/libraries/Session/Session.php */
630?>