Skip to content

Commit

Permalink
Merge pull request bcit-ci#2026 from johnathancroom/keep_flash_data_a…
Browse files Browse the repository at this point in the history
…rray

keep_flashdata accepts array
  • Loading branch information
narfbg committed Nov 25, 2012
2 parents 4678a86 + 742d2db commit c854bc1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion system/libraries/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,22 @@ public function set_flashdata($newdata = array(), $newval = '')
/**
* Keeps existing flashdata available to next request.
*
* @param string Item key
* @param mixed Item key(s)
* @return void
*/
public function keep_flashdata($key)
{

if (is_array($key))
{
foreach ($key as $k)
{
$this->keep_flashdata($k);
}

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;
Expand Down
3 changes: 2 additions & 1 deletion user_guide_src/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ Release Date: Not Released
- Added ``all_flashdata()`` method to session class. Returns an associative array of only flashdata.
- Added ``has_userdata()`` method to verify existence of userdata item.
- Added ``tempdata()``, ``set_tempdata()``, and ``unset_tempdata()`` methods for manipulating tempdata.
- ``keep_flashdata()`` now accepts an array of keys.
- :doc:`File Uploading Library <libraries/file_uploading>` changes include:
- Added *max_filename_increment* config setting.
- Added an "index" parameter to the ``data()`` method.
Expand Down Expand Up @@ -2671,4 +2672,4 @@ Version Beta 1.0

Release Date: February 28, 2006

First publicly released version.
First publicly released version.
4 changes: 3 additions & 1 deletion user_guide_src/source/libraries/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,20 @@ 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();


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
========
Expand Down

0 comments on commit c854bc1

Please sign in to comment.