通过codeigniter中的重定向功能发布数据 [英] post data via redirect function in codeigniter

查看:162
本文介绍了通过codeigniter中的重定向功能发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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中的重定向功能发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆