Welcome Guest, Not a member yet? Register   Sign In
session flashdata not work correctly in codeigniter 2.2
#1

Hi guys!, can you help me?
I have a problem with session flashdata. never the message containing the session is displayed.

I have this routes:
PHP Code:
//index is a subfolder into the controllers folder
//user is a controller
$route['login'            'index/user/showLogin';
$route['do_login'         'index/user/doLogin';
$route['register'         'index/user/showRegister';
$route['do_register'      'index/user/doRegister'

user.php controller:

PHP Code:
public function showRegister()
{
 
  $this->template->set('title''test register');
 
  $this->template->load('template''index/register'$data);
}

public function 
doRegister()
{
 
  $this->form_validation->set_rules('email'     'Email'               'required|trim|max_length[30]|xss_clean|valid_email|is_unique[users.email]|');
 
  $this->form_validation->set_rules('password'  'Password'          'required|trim|min_length[6]|max_length[20]|xss_clean|alpha_dash');
 
  $this->form_validation->set_rules('rrpassword''Re Password'  'required|trim|min_length[6]|max_length[20]|xss_clean|matches[password]|alpha_dash');

 
  if($this->form_validation->run() == FALSE)
 
  {
 
   $this->showRegister();
 
  }
 
  else
 
  {
 
      $email      $this->input->post('email');
 
      $pass       $this->input->post('password');
 
      $password   $this->bcrypt->hash_password($pass);

 
      // check if the password was encrypted
 
      if ($this->bcrypt->check_password($pass$password))
 
      {
 
          $data =array(
 
              'email'     => $email,
 
              'password'  => $password,
 
          );

 
          $insert $this->user_model->register($data);

 
          if(!$insert)
 
          {
 
              echo 'error';
 
          }
 
          $this->session->set_flashdata('info''registered');
 
          redirect('login''refresh');
 
      }
 
      else
 
      {
 
          $this->session->set_flashdata('info''Oops.. error...');
 
          redirect(base_url('login'), 'refresh');
 
      }
 
   }
 
 

to display messages I do this in the view "login":

PHP Code:
<div class="alert alert-info alert-dismissible" role="alert">
 
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
 
  Test: <?php echo $this->session->flashdata('info'); ?>
</div> 

But never the message is printed. i Tried this:

PHP Code:
$this->session->set_flashdata('info''test......');
$this->session->keep_flashdata('info');
redirect('login''refresh'); 

But not works. Also add the favicon.ico to the root folder, but does not work. I'm trying to fix it a few hours ago. It may be the version of PHP?
Also i tried this:

PHP Code:
$this->session->sess_create();
$this->session->set_flashdata('info''test......');
redirect('login''refresh'); 
Reply


Messages In This Thread
session flashdata not work correctly in codeigniter 2.2 - by Smith - 11-27-2014, 08:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB