Welcome Guest, Not a member yet? Register   Sign In
flashdata not cleared
#1

[eluser]shinokada[/eluser]
According to the user manual, it says flashdata are automatically cleared.

However it does not disappear in the following code. It shows "Invalid email. Please try again!" always.

How long flash data keep it data? Is it for 5 min as a default like session data?

Controller

Code:
<?php

class Welcome extends Controller {
  function  __construct(){
    parent::Controller();
    session_start();
    $this->output->enable_profiler(FALSE);
  }
function index(){
    $this->load->helper('form');
      $this->output->cache(30);
    $data['title'] = "Welcome to Claudia's Kids";
    
    $this->load->vars($data);
    $this->load->view('subscribe');
  }
  
function subscribe(){
      if ($this->input->post('email')){
          $this->load->helper('email');
        if (!valid_email($this->input->post('email'))){
            $this->session->set_flashdata('subscribe_msg', 'Invalid email. Please try again!');
            redirect('welcome/index','refresh');
        }
        // $this->MSubscribers->createSubscriber();
        $this->session->set_flashdata('subscribe_msg', 'Thanks for subscribing!');
        redirect('welcome/index','refresh');
      }else{
        $this->session->set_flashdata('subscribe_msg', "You did not fill out the form!");
        redirect('welcome/index','refresh');          
      }
  }
}


Views/subscribe.php

Code:
<?php
if ($this->session->flashdata('subscribe_msg')){
    echo "<div class='message'>";
    echo $this->session->flashdata('subscribe_msg');
    echo "</div>";
}
echo form_open("welcome/subscribe");
echo form_fieldset('Subscribe To Our Newsletter');
$data = array('name'=>'name', 'id' => 'name','size'=>'25');
echo "<p><label for='name'>Name</label><br/>";
echo form_input($data) . "</p>";
$data = array('name'=>'email', 'id' => 'email', 'size'=>'25');
echo "<p><label for='email'>Email</label><br/>";
echo form_input($data) . "</p>";
echo form_submit("submit","subscribe");
echo form_fieldset_close();
echo form_close();
?&gt;


Messages In This Thread
flashdata not cleared - by El Forum - 11-01-2009, 09:32 AM
flashdata not cleared - by El Forum - 11-01-2009, 09:45 AM
flashdata not cleared - by El Forum - 11-01-2009, 09:50 AM
flashdata not cleared - by El Forum - 11-01-2009, 11:53 AM
flashdata not cleared - by El Forum - 11-01-2009, 12:23 PM
flashdata not cleared - by El Forum - 11-01-2009, 03:24 PM
flashdata not cleared - by El Forum - 11-01-2009, 03:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB