在codeiginter中使用redirect()函数来发布数据数组或单个变量字符串数据有没有办法或一些技巧?
Is there ever a way or some tricks to post an array of data or a single variable string data using redirect() function in codeiginter?
推荐答案当使用 redirect 你从一个控制器或另一个通过这个过程,所有的发布数据被销毁除非你存储在一个会话,这里是我如何it
when using redirect you go from one controller or another by this process all post data are destroyed unless you stored them on a session, here is how i do it
$data = array('firstname'=>'fname','lastname'=>'lastname'); // i store data to flashdata $this->session->set_flashdata('lolwut',$data); // after storing i redirect it to the controller redirect('controller/method')您的重定向控制器上可以通过 $ this-> session-> flashdata('lolwut') 访问它我使用 flashdata 不 userdata , flashdata
so on your redirected controller you can access it via $this->session->flashdata('lolwut') note that i am using flashdata not userdata, flashdata destroys itself on the next process.
阅读更多flashdata这里 SESSION课程
read more flashdata here SESSION CLASS
更多推荐
通过codeigniter中的重定向功能发布数据
发布评论