blob: 68819a665582704c157ce64c146224a2723f62be [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.
Darren Hill5073a372011-08-31 13:54:19 -040021 * By default, the native PHP session driver will load, but the 'sess_driver' config/param item (see above) can be
22 * used to specify the 'cookie' 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();
dchill42c5872252012-07-30 14:53:11 -040067 $this->valid_drivers = array('Session_native', 'Session_cookie');
Darren Hillc4e266b2011-08-30 15:40:27 -040068 $key = 'sess_valid_drivers';
69 $drivers = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
70 if ($drivers)
71 {
dchill4277ee3fd2012-07-24 11:50:01 -040072 if ( ! is_array($drivers)) $drivers = array($drivers);
Darren Hillc4e266b2011-08-30 15:40:27 -040073
74 // Add driver names to valid list
75 foreach ($drivers as $driver)
76 {
dchill4277ee3fd2012-07-24 11:50:01 -040077 if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers)))
Darren Hillc4e266b2011-08-30 15:40:27 -040078 {
79 $this->valid_drivers[] = $driver;
80 }
81 }
82 }
83
84 // Get driver to load
85 $key = 'sess_driver';
86 $driver = (isset($params[$key])) ? $params[$key] : $CI->config->item($key);
dchill4277ee3fd2012-07-24 11:50:01 -040087 if ( ! $driver) $driver = 'cookie';
88 if ( ! in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers)))
Darren Hillc4e266b2011-08-30 15:40:27 -040089 {
90 $this->valid_drivers[] = 'Session_'.$driver;
91 }
92
93 // Save a copy of parameters in case drivers need access
94 $this->params = $params;
95
96 // Load driver and get array reference
97 $this->load_driver($driver);
Darren Hillc4e266b2011-08-30 15:40:27 -040098
99 // Delete 'old' flashdata (from last request)
100 $this->_flashdata_sweep();
101
102 // Mark all new flashdata as old (data will be deleted before next request)
103 $this->_flashdata_mark();
104
105 // Delete expired tempdata
106 $this->_tempdata_sweep();
107
Darren Hill5073a372011-08-31 13:54:19 -0400108 log_message('debug', 'CI_Session routines successfully run');
Darren Hillc4e266b2011-08-30 15:40:27 -0400109 }
110
111 /**
112 * Loads session storage driver
113 *
Darren Hill5073a372011-08-31 13:54:19 -0400114 * @param string Driver classname
115 * @return object Loaded driver object
Darren Hillc4e266b2011-08-30 15:40:27 -0400116 */
117 public function load_driver($driver)
118 {
119 // Save reference to most recently loaded driver as library default
120 $this->current = parent::load_driver($driver);
dchill42b1855372012-07-31 09:32:23 -0400121 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400122 return $this->current;
123 }
124
125 /**
126 * Select default session storage driver
127 *
Darren Hill5073a372011-08-31 13:54:19 -0400128 * @param string Driver classname
129 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400130 */
131 public function select_driver($driver)
132 {
133 // Validate driver name
dchill42c5872252012-07-30 14:53:11 -0400134 $lowername = strtolower(str_replace('CI_', '', $driver));
Darren Hillc4e266b2011-08-30 15:40:27 -0400135 if (in_array($lowername, array_map('strtolower', $this->valid_drivers)))
136 {
dchill42b1855372012-07-31 09:32:23 -0400137 // See if driver is loaded
138 $child = str_replace($this->lib_name.'_', '', $driver);
139 if (isset($this->$child))
Darren Hillc4e266b2011-08-30 15:40:27 -0400140 {
dchill42b1855372012-07-31 09:32:23 -0400141 $this->current = $this->$child;
142 $this->userdata =& $this->current->get_userdata();
Darren Hillc4e266b2011-08-30 15:40:27 -0400143 }
144 else
145 {
146 $this->load_driver($driver);
147 }
148 }
149 }
150
151 /**
152 * Destroy the current session
153 *
Darren Hill5073a372011-08-31 13:54:19 -0400154 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400155 */
156 public function sess_destroy()
157 {
158 // Just call destroy on driver
159 $this->current->sess_destroy();
160 }
161
162 /**
163 * Regenerate the current session
164 *
Darren Hill5073a372011-08-31 13:54:19 -0400165 * @param boolean Destroy session data flag (default: false)
166 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400167 */
168 public function sess_regenerate($destroy = false)
169 {
170 // Just call regenerate on driver
171 $this->current->sess_regenerate($destroy);
172 }
173
174 /**
175 * Fetch a specific item from the session array
176 *
Darren Hill5073a372011-08-31 13:54:19 -0400177 * @param string Item key
dchill42c5872252012-07-30 14:53:11 -0400178 * @return string Item value or NULL if not found
Darren Hillc4e266b2011-08-30 15:40:27 -0400179 */
180 public function userdata($item)
181 {
dchill42c5872252012-07-30 14:53:11 -0400182 // Return value or NULL if not found
dchill4277ee3fd2012-07-24 11:50:01 -0400183 return ( ! isset($this->userdata[$item])) ? NULL : $this->userdata[$item];
Darren Hillc4e266b2011-08-30 15:40:27 -0400184 }
185
186 /**
187 * Fetch all session data
188 *
189 * @return array User data array
190 */
191 public function all_userdata()
192 {
193 // Return entire array
dchill4277ee3fd2012-07-24 11:50:01 -0400194 return ( ! isset($this->userdata)) ? NULL : $this->userdata;
Darren Hillc4e266b2011-08-30 15:40:27 -0400195 }
196
197 /**
dchill42c5079de2012-07-23 10:53:47 -0400198 * Fetch all flashdata
199 *
200 * @return array Flash data array
201 */
202 public function all_flashdata()
203 {
204 $out = array();
205
206 // loop through all userdata
207 foreach ($this->all_userdata() as $key => $val)
208 {
dchill42c5872252012-07-30 14:53:11 -0400209 // if it contains flashdata, add it
dchill42c5079de2012-07-23 10:53:47 -0400210 if (strpos($key, self::FLASHDATA_KEY.self::FLASHDATA_OLD) !== FALSE)
211 {
dchill42b1855372012-07-31 09:32:23 -0400212 $key = str_replace(self::FLASHDATA_KEY.self::FLASHDATA_OLD, '', $key);
dchill42c5079de2012-07-23 10:53:47 -0400213 $out[$key] = $val;
214 }
215 }
216 return $out;
217 }
218
219 /**
Darren Hillc4e266b2011-08-30 15:40:27 -0400220 * Add or change data in the "userdata" array
221 *
Darren Hill5073a372011-08-31 13:54:19 -0400222 * @param mixed Item name or array of items
223 * @param string Item value or empty string
224 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400225 */
226 public function set_userdata($newdata = array(), $newval = '')
227 {
228 // Wrap params as array if singular
229 if (is_string($newdata))
230 {
231 $newdata = array($newdata => $newval);
232 }
233
234 // Set each name/value pair
235 if (count($newdata) > 0)
236 {
237 foreach ($newdata as $key => $val)
238 {
239 $this->userdata[$key] = $val;
240 }
241 }
242
243 // Tell driver data changed
244 $this->current->sess_save();
245 }
246
247 /**
248 * Delete a session variable from the "userdata" array
249 *
Darren Hill5073a372011-08-31 13:54:19 -0400250 * @param mixed Item name or array of item names
251 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400252 */
253 public function unset_userdata($newdata = array())
254 {
255 // Wrap single name as array
256 if (is_string($newdata))
257 {
258 $newdata = array($newdata => '');
259 }
260
261 // Unset each item name
262 if (count($newdata) > 0)
263 {
264 foreach ($newdata as $key => $val)
265 {
266 unset($this->userdata[$key]);
267 }
268 }
269
270 // Tell driver data changed
271 $this->current->sess_save();
272 }
273
274 /**
275 * Determine if an item exists
276 *
Darren Hill5073a372011-08-31 13:54:19 -0400277 * @param string Item name
278 * @return boolean
Darren Hillc4e266b2011-08-30 15:40:27 -0400279 */
280 public function has_userdata($item)
281 {
282 // Check for item name
283 return isset($this->userdata[$item]);
284 }
285
286 /**
287 * Add or change flashdata, only available until the next request
288 *
Darren Hill5073a372011-08-31 13:54:19 -0400289 * @param mixed Item name or array of items
290 * @param string Item value or empty string
291 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400292 */
293 public function set_flashdata($newdata = array(), $newval = '')
294 {
295 // Wrap item as array if singular
296 if (is_string($newdata))
297 {
298 $newdata = array($newdata => $newval);
299 }
300
301 // Prepend each key name and set value
302 if (count($newdata) > 0)
303 {
304 foreach ($newdata as $key => $val)
305 {
306 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
307 $this->set_userdata($flashdata_key, $val);
308 }
309 }
310 }
311
312 /**
313 * Keeps existing flashdata available to next request.
314 *
Darren Hill5073a372011-08-31 13:54:19 -0400315 * @param string Item key
316 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400317 */
318 public function keep_flashdata($key)
319 {
dchill42c5079de2012-07-23 10:53:47 -0400320 // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep()
321 // Note the function will return NULL if the $key provided cannot be found
Darren Hillc4e266b2011-08-30 15:40:27 -0400322 $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
323 $value = $this->userdata($old_flashdata_key);
324
325 $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
326 $this->set_userdata($new_flashdata_key, $value);
327 }
328
329 /**
330 * Fetch a specific flashdata item from the session array
331 *
Darren Hill5073a372011-08-31 13:54:19 -0400332 * @param string Item key
333 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400334 */
335 public function flashdata($key)
336 {
337 // Prepend key and retrieve value
338 $flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key;
339 return $this->userdata($flashdata_key);
340 }
341
342 /**
343 * Add or change tempdata, only available
344 * until expiration
345 *
Darren Hill5073a372011-08-31 13:54:19 -0400346 * @param mixed Item name or array of items
347 * @param string Item value or empty string
348 * @param int Item lifetime in seconds or 0 for default
349 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400350 */
351 public function set_tempdata($newdata = array(), $newval = '', $expire = 0)
352 {
353 // Set expiration time
354 $expire = time() + ($expire ? $expire : self::TEMP_EXP_DEF);
355
356 // Wrap item as array if singular
357 if (is_string($newdata))
358 {
359 $newdata = array($newdata => $newval);
360 }
361
362 // Get or create expiration list
363 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400364 if ( ! $expirations)
Darren Hillc4e266b2011-08-30 15:40:27 -0400365 {
366 $expirations = array();
367 }
368
369 // Prepend each key name and set value
370 if (count($newdata) > 0)
371 {
372 foreach ($newdata as $key => $val)
373 {
374 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
375 $expirations[$tempdata_key] = $expire;
376 $this->set_userdata($tempdata_key, $val);
377 }
378 }
379
380 // Update expiration list
381 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
382 }
383
384 /**
385 * Delete a temporary session variable from the "userdata" array
386 *
Darren Hill5073a372011-08-31 13:54:19 -0400387 * @param mixed Item name or array of item names
388 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400389 */
390 public function unset_tempdata($newdata = array())
391 {
392 // Get expirations list
393 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400394 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400395 {
396 // Nothing to do
397 return;
398 }
399
400 // Wrap single name as array
401 if (is_string($newdata))
402 {
403 $newdata = array($newdata => '');
404 }
405
406 // Prepend each item name and unset
407 if (count($newdata) > 0)
408 {
409 foreach ($newdata as $key => $val)
410 {
411 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
412 unset($expirations[$tempdata_key]);
413 $this->unset_userdata($tempdata_key);
414 }
415 }
416
417 // Update expiration list
418 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
419 }
420
421 /**
422 * Fetch a specific tempdata item from the session array
423 *
Darren Hill5073a372011-08-31 13:54:19 -0400424 * @param string Item key
425 * @return string
Darren Hillc4e266b2011-08-30 15:40:27 -0400426 */
427 public function tempdata($key)
428 {
429 // Prepend key and return value
430 $tempdata_key = self::FLASHDATA_KEY.self::FLASHDATA_EXP.$key;
431 return $this->userdata($tempdata_key);
432 }
433
434 /**
435 * Identifies flashdata as 'old' for removal
436 * when _flashdata_sweep() runs.
437 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400438 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400439 * @return void
440 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400441 protected function _flashdata_mark()
Darren Hillc4e266b2011-08-30 15:40:27 -0400442 {
443 $userdata = $this->all_userdata();
444 foreach ($userdata as $name => $value)
445 {
446 $parts = explode(self::FLASHDATA_NEW, $name);
447 if (is_array($parts) && count($parts) === 2)
448 {
449 $new_name = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$parts[1];
450 $this->set_userdata($new_name, $value);
451 $this->unset_userdata($name);
452 }
453 }
454 }
455
456 /**
457 * Removes all flashdata marked as 'old'
458 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400459 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400460 * @return void
461 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400462 protected function _flashdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400463 {
464 $userdata = $this->all_userdata();
465 foreach ($userdata as $key => $value)
466 {
467 if (strpos($key, self::FLASHDATA_OLD))
468 {
469 $this->unset_userdata($key);
470 }
471 }
472 }
473
474 /**
475 * Removes all expired tempdata
476 *
Darren Hilla2ae6572011-09-01 07:36:26 -0400477 * @access protected
Darren Hillc4e266b2011-08-30 15:40:27 -0400478 * @return void
479 */
Darren Hilla2ae6572011-09-01 07:36:26 -0400480 protected function _tempdata_sweep()
Darren Hillc4e266b2011-08-30 15:40:27 -0400481 {
482 // Get expirations list
483 $expirations = $this->userdata(self::EXPIRATION_KEY);
dchill4277ee3fd2012-07-24 11:50:01 -0400484 if ( ! $expirations || ! count($expirations))
Darren Hillc4e266b2011-08-30 15:40:27 -0400485 {
486 // Nothing to do
487 return;
488 }
489
490 // Unset expired elements
491 $now = time();
492 $userdata = $this->all_userdata();
493 foreach ($userdata as $key => $value)
494 {
495 if (strpos($key, self::FLASHDATA_EXP) && $expirations[$key] < $now)
496 {
497 unset($expirations[$key]);
498 $this->unset_userdata($key);
499 }
500 }
501
502 // Update expiration list
503 $this->set_userdata(self::EXPIRATION_KEY, $expirations);
504 }
505}
Darren Hill5073a372011-08-31 13:54:19 -0400506// END CI_Session Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400507
508
509/**
Darren Hill5073a372011-08-31 13:54:19 -0400510 * CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400511 *
Darren Hill5073a372011-08-31 13:54:19 -0400512 * Extend this class to make a new CI_Session driver.
513 * A CI_Session driver basically manages an array of name/value pairs with some sort of storage mechanism.
514 * 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 -0400515 * session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler
516 * to remove deleted data (sess_destroy), and an access handler to expose the data (get_userdata).
Darren Hill5073a372011-08-31 13:54:19 -0400517 * Put your driver in the libraries/Session/drivers folder anywhere in the loader paths. This includes the
518 * application directory, the system directory, or any path you add with $CI->load->add_package_path().
519 * Your driver must be named CI_Session_<name>, and your filename must be Session_<name>.php,
520 * preferably also capitalized. (e.g.: CI_Session_foo in libraries/Session/drivers/Session_foo.php)
521 * 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 -0400522 * object. (e.g.: $config['sess_driver'] = 'foo'; OR $CI->load->driver('session', array('sess_driver' => 'foo')); )
523 * Already provided are the Native driver, which manages the native PHP $_SESSION array, and
524 * the Cookie driver, which manages the data in a browser cookie, with optional extra storage in a database table.
525 *
Darren Hill5073a372011-08-31 13:54:19 -0400526 * @package CodeIgniter
527 * @subpackage Libraries
Darren Hillc4e266b2011-08-30 15:40:27 -0400528 * @category Sessions
Darren Hill5073a372011-08-31 13:54:19 -0400529 * @author ExpressionEngine Dev Team
Darren Hillc4e266b2011-08-30 15:40:27 -0400530 */
Darren Hill5073a372011-08-31 13:54:19 -0400531abstract class CI_Session_driver extends CI_Driver {
Darren Hillc4e266b2011-08-30 15:40:27 -0400532 /**
533 * Decorate
534 *
535 * Decorates the child with the parent driver lib's methods and properties
536 *
537 * @param object Parent library object
538 * @return void
539 */
540 public function decorate($parent)
541 {
542 // Call base class decorate first
543 parent::decorate($parent);
544
dchill42c5872252012-07-30 14:53:11 -0400545 // Call initialize method now that driver has access to $this->_parent
Darren Hillc4e266b2011-08-30 15:40:27 -0400546 $this->initialize();
547 }
548
549 /**
550 * __call magic method
551 *
552 * Handles access to the parent driver library's methods
553 *
Darren Hill5073a372011-08-31 13:54:19 -0400554 * @param string Library method name
555 * @param array Method arguments (default: none)
Darren Hillc4e266b2011-08-30 15:40:27 -0400556 * @return mixed
557 */
558 public function __call($method, $args = array())
559 {
560 // Make sure the parent library uses this driver
dchill42c5872252012-07-30 14:53:11 -0400561 $this->_parent->select_driver(get_class($this));
Darren Hillc4e266b2011-08-30 15:40:27 -0400562 return parent::__call($method, $args);
563 }
564
565 /**
566 * Initialize driver
567 *
Darren Hill5073a372011-08-31 13:54:19 -0400568 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400569 */
570 protected function initialize()
571 {
572 // Overload this method to implement initialization
573 }
574
575 /**
576 * Save the session data
577 *
578 * Data in the array has changed - perform any storage synchronization necessary
579 * The child class MUST implement this abstract method!
580 *
Darren Hill5073a372011-08-31 13:54:19 -0400581 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400582 */
583 abstract public function sess_save();
584
585 /**
586 * Destroy the current session
587 *
588 * Clean up storage for this session - it has been terminated
589 * The child class MUST implement this abstract method!
590 *
Darren Hill5073a372011-08-31 13:54:19 -0400591 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400592 */
593 abstract public function sess_destroy();
594
595 /**
596 * Regenerate the current session
597 *
598 * Regenerate the session id
599 * The child class MUST implement this abstract method!
600 *
Darren Hill5073a372011-08-31 13:54:19 -0400601 * @param boolean Destroy session data flag (default: false)
602 * @return void
Darren Hillc4e266b2011-08-30 15:40:27 -0400603 */
604 abstract public function sess_regenerate($destroy = false);
605
606 /**
607 * Get a reference to user data array
608 *
Darren Hill5073a372011-08-31 13:54:19 -0400609 * Give array access to the main CI_Session object
Darren Hillc4e266b2011-08-30 15:40:27 -0400610 * The child class MUST implement this abstract method!
611 *
Darren Hill5073a372011-08-31 13:54:19 -0400612 * @return array Reference to userdata
Darren Hillc4e266b2011-08-30 15:40:27 -0400613 */
614 abstract public function &get_userdata();
615}
Darren Hill5073a372011-08-31 13:54:19 -0400616// END CI_Session_driver Class
Darren Hillc4e266b2011-08-30 15:40:27 -0400617
618
619/* End of file Session.php */
620/* Location: ./system/libraries/Session/Session.php */
621?>