Welcome Guest, Not a member yet? Register   Sign In
Simple function to get all the flashdata
#1

[eluser]Unknown[/eluser]
hi, need to get just the flashdata?
(maybe useful to repopulate a form if you store all your $_POST in flashdata session)
here a simple php script in a custom Session Class
(CI -version 1.7.2)
any suggestion is appreciated
Mirko
Code:
class MY_Session extends CI_Session {
function  __construct() {
  parent::CI_Session();
}

/**
  * Gets all the flashdata stored in CI session
  *
  * @author Mirko Mariotti
  * @return Array The flashdata array
  */
function all_flashdata() {
  $all_flashdata=$res=array();
  foreach($this->all_userdata() as $k=>$v) {
   if(preg_match('/^flash:old:(.+)/', $k, $res)) {
    $all_flashdata[$res[1]] = $this->userdata($this->flashdata_key.':old:'.$res[1]);
   }
  }
  return $all_flashdata;
}

greetings




Theme © iAndrew 2016 - Forum software by © MyBB