会话闪存数据不适用于表单提交


Session flashdata doesn´t work on form submit

我正在使用离子身份验证"库"作为codeigniter(https://github.com/benedmunds/CodeIgniter-Ion-Auth),并且我在闪存数据方面遇到了问题。这是代码摘要:

public function reset_password($code = NULL)
{
    if (!$code)show_404();
    $this->user = $this->ion_auth->forgotten_password_check($code);
    if ($this->user)
    {
        //setting the rules
        if ($this->form_validation->run() == false)
        {
            //more code
            $this->_get_csrf_nonce();
            /*
              One of the things this function (_get_csrf_nonce) makes is:
              $this->session->set_flashdata('csrfkey', $key);
              $this->session->set_flashdata('csrfvalue', $value); 
            */
            //The next thing is load the view with the form
        }
        else //form is running
        {
            echo "flashdata csrfkeyvalue: ".$this->session->flashdata('csrfvalue')."<br>";
            die;
            //more code, but not important by the moment
        }
    }
}

好吧,当提交表单时,$this->session->flashdata('csrfvalue')的回声没有任何显示。
如果我做这样的东西:

private function _get_csrf_nonce(){
    /*$this->load->helper('string');
    $key   = random_string('alnum', 8);
    $value = random_string('alnum', 20);
    $this->session->set_flashdata('csrfkey', $key);*/
    $this->session->set_flashdata('csrfvalue', $value);
    redirect(base_url("auth/test"));
    //return array($key => $value);
}
public function test()
{
    echo "flashdata csrfkeyvalue: ".$this->session->flashdata('csrfvalue')."<br>";
}

在这种情况下...它有效。我对表单使用的视图与此非常相似:https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/views/auth/reset_password.php

谢谢。

解决方案

经过一番争吵,我正在寻找可以在加载表单视图和提交表单之间提出新请求的东西......最后,我发现了(我不记得了)一个通过控制器请求的 javascript(根据本教程翻译一些文本:http://www.student.kuleuven.be/~r0304874/blog/international-javascript-files-in-codeigniter.html)。我是这样加载的:

<script src="<?=site_url('jsloader/login.js');?>" type="text/javascript"></script>

谢谢。