我有两个控制器,如Controller文件夹中的doc.php、user.php和view文件夹中的registration.php,它们都有一个注册表。我想通过user.php将注册信息从registration.php传递到doc.php控制器。我该怎么做?需要帮助。
您的代码点火器版本是什么?2.x还是3.x?
尝试使用会话来保存您的阵列。
要在控制器构造函数中手动初始化Session类,请使用以下方法:
$this->load->library();
加载后,会话库对象将使用可用
$this->session
您可以使用以下代码设置会话名称:
$this->session->your_session_name;
使用此项在会话中添加项目:
$this->session->your_session_name('item_one');
要检索您的会话,请使用以下代码:
$this->session->your_session_name;
检查CodeIgniter 3.X
检查CodeIgniter 2.X
在CodeIgnitor中,通常使用会话对象在控制器之间传递数据。例如:
// initialise the session object
$this->load->library('session');
// save the array to the session
$this->session->set_userdata('reg_info', $reg_info);
// retrieve the array in the other controller:
$this->session->userdata('reg_info');
有关CodeIgnitor会话对象的更多信息,请参阅文档。