我正在使用ion-auth“库”作为代码点火器(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>";
}在这种情况下..。它起作用了。我所使用的表单视图非常类似于以下内容:password.php
谢谢。
发布于 2016-03-23 01:33:22
解决方案
经过一点斗争,我正在寻找什么东西,可以提出一个新的请求之间的视图加载和表单被提交.最后,我发现(我不记得)一个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>谢谢。
https://stackoverflow.com/questions/36168304
复制相似问题