summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Session/Session.php26
-rw-r--r--user_guide_src/source/libraries/sessions.rst4
2 files changed, 21 insertions, 9 deletions
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index 96e65f154..81d63c304 100644
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -389,18 +389,28 @@ class CI_Session extends CI_Driver_Library {
/**
* Keeps existing flashdata available to next request.
*
- * @param string Item key
+ * @param mixed Item key
* @return void
*/
- public function keep_flashdata($key)
+ public function keep_flashdata($data)
{
- // '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);
+ // Wrap item as array if singular
+ if (is_string($data))
+ {
+ $data = array($data);
+ }
+
+ foreach($data as $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);
+
+ $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
+ $this->set_userdata($new_flashdata_key, $value);
+ }
- $new_flashdata_key = self::FLASHDATA_KEY.self::FLASHDATA_NEW.$key;
- $this->set_userdata($new_flashdata_key, $value);
}
// ------------------------------------------------------------------------
diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
index ee7fb0b1c..aecad3164 100644
--- a/user_guide_src/source/libraries/sessions.rst
+++ b/user_guide_src/source/libraries/sessions.rst
@@ -195,7 +195,7 @@ set_userdata().
To read a flashdata variable::
$this->session->flashdata('item');
-
+
An array of all flashdata can be retrieved as follows::
$this->session->all_flashdata();
@@ -203,10 +203,12 @@ An array of all flashdata can be retrieved as follows::
If you find that you need to preserve a flashdata variable through an
additional request, you can do so using the keep_flashdata() function.
+You can either pass a single item or an array of flashdata items to keep.
::
$this->session->keep_flashdata('item');
+ $this->session->keep_flashdata(array('item1', 'item2', 'item3'));
Tempdata
========