From 8d8543da992985ae61a6903a138d949f189721e9 Mon Sep 17 00:00:00 2001 From: Johnathan Croom Date: Sun, 25 Nov 2012 10:36:57 -0700 Subject: Improved array keey_flashdata + Changelog --- system/libraries/Session/Session.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'system/libraries/Session') diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index 910b99936..9b011dea3 100644 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -392,24 +392,26 @@ class CI_Session extends CI_Driver_Library { * @param mixed Item key(s) * @return void */ - public function keep_flashdata($data) + public function keep_flashdata($key) { - // Wrap item as array if singular - if (!is_array($data)) - { - $data = array($data); - } - foreach ($data as $key) + if (is_array($key)) { - // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep() - // Note the function will return NULL if the $key provided cannot be found - $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; - $value = $this->userdata($old_flashdata_key); + foreach ($key as $k) + { + $this->keep_flashdata($k); + } - $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; - $this->set_userdata($new_flashdata_key, $value); + return; } + + // 'old' flashdata gets removed. Here we mark all flashdata as 'new' to preserve it from _flashdata_sweep() + // Note the function will return NULL if the $key provided cannot be found + $old_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_OLD.$key; + $value = $this->userdata($old_flashdata_key); + + $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key; + $this->set_userdata($new_flashdata_key, $value); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b