【发布时间】:2011-11-29 11:09:49
【问题描述】:
我正在使用 codeigniter,在我的控制器中我无法设置 flashdata,但我可以设置用户数据
/**
* this will send the requests for the gmail wrapper
* @return void
* @author Sandaruwan
* */
function send_contacts()
{
$contacts = $this->input->post('contact');
if (count($contacts) != 0 && is_array($contacts))
{
$data = $this->gmailmanager->send_messeges($contacts);
echo "error message ===>"; print_r($this->message->get_message ()); echo "<br/>";
$this->session->set_flashdata('message',$this->message->get_message ());
echo "flash data ===>"; print_r($this->session->flashdata('message')); echo "<br/>";
$this->session->set_userdata('user',$this->message->get_message ());
echo "user data ===>"; print_r($this->session->userdata('user')); echo "<br/>";
exit;
redirect('connections/connection_inviter/invite');
}
else
{
$this->message->set_information(array(_('You have not selected a conatact!')));
$this->session->set_flashdata('message',$this->message->get_message ());
redirect('connections/connection_inviter/invite');
}
}
这是结果
error message ===>
Warning
Email sending error!
flash data ===>
user data ===>
Warning
Email sending error
!
问题是我可以得到error message 和userdata 但不能得到flashdata,我不知道为什么我不能在初始化后立即得到flashdata。
在某些控制器中,flashdata 可以完美运行。
更新
function invite() {
$this->load->library("connections/Outlookmanager");
print_r($this->ci->session->flashdata('message'); die;
//Invite friends links
$this->data['is_windows']=$this->outlookmanager->is_windows_user();
$this->load->view('connections/invite_friends', $this->data);
}
当我在function invite() 中打印flashdata 时,它没有打印。
更新
嗯嗯。其实有一个很有意思的问题,
我收到错误消息Email sending error 我将其更改为err 现在闪存数据正常工作。我再次将消息更改为Email sending error,但它再次无法正常工作。然后我再次将其更改为err 然后再次使用 flashdata 。
这是什么,我认为是错误消息长度导致了这里的问题,我不知道为什么
【问题讨论】:
-
请告诉我你为什么要给我 (-) 。我一整天都在坚持:(
-
也尝试了keep_flashdata但不起作用
标签: php codeigniter