summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session/Session.php
diff options
context:
space:
mode:
authordchill42 <dchill42@gmail.com>2012-08-29 03:37:27 +0200
committerdchill42 <dchill42@gmail.com>2012-08-29 03:37:27 +0200
commit3cecd8234d3bb9045e9cc41e15f603a6e87c5fac (patch)
tree5fb633b86024918c2f1c6f901ae8243ac6e3d43c /system/libraries/Session/Session.php
parent08c8304778e573d725b5565f350e44c34fb0d830 (diff)
Extracted cookie database saves to shutdown and cleaned up code
Signed-off-by: dchill42 <dchill42@gmail.com>
Diffstat (limited to 'system/libraries/Session/Session.php')
-rwxr-xr-xsystem/libraries/Session/Session.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index 1f24456a4..1195ed955 100755
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -42,6 +42,7 @@ class CI_Session extends CI_Driver_Library {
public $params = array();
protected $current = null;
protected $userdata = array();
+ protected $loaded = array();
const FLASHDATA_KEY = 'flash';
const FLASHDATA_NEW = ':new:';
@@ -112,6 +113,22 @@ class CI_Session extends CI_Driver_Library {
}
/**
+ * CI_Session destructor
+ *
+ * The destructor calls shutdown() on each loaded driver
+ */
+ public function __destruct()
+ {
+ // Call shutdown for each loaded driver
+ foreach ($this->loaded as $driver)
+ {
+ $this->$driver->shutdown();
+ }
+
+ log_message('debug', 'CI_Session Class Shutdown');
+ }
+
+ /**
* Loads session storage driver
*
* @param string Driver classname
@@ -122,6 +139,14 @@ class CI_Session extends CI_Driver_Library {
// Save reference to most recently loaded driver as library default and sync userdata
$this->current = parent::load_driver($driver);
$this->userdata =& $this->current->get_userdata();
+
+ // Mark driver as loaded
+ if (!in_array($driver, $this->loaded))
+ {
+ $this->loaded[] = $driver;
+ }
+
+ // Return driver object
return $this->current;
}
@@ -582,6 +607,16 @@ abstract class CI_Session_driver extends CI_Driver {
}
/**
+ * Shut down driver
+ *
+ * @return void
+ */
+ public function shutdown()
+ {
+ // Overload this method to implement shutdown
+ }
+
+ /**
* Save the session data
*
* Data in the array has changed - perform any storage synchronization necessary