[英]How to pass data from one function to another in codeigniter by using session?
Am trying to pass some data from one function to another when i set the data into session and print the session data i get the correct data, but whe trying to use the data in another function i get the word "Assets" i dont know where this word come from. 当我将数据设置为会话并打印会话数据时,我试图将一些数据从一个函数传递给另一函数,但我获得了正确的数据,但是试图在另一函数中使用数据时,我得到了“资产”一词,我不知道在哪里这个词来自。 Session library is auto loaded.Any help please.
会话库已自动加载。请提供任何帮助。 These are my codes:
这些是我的代码:
First function: 第一个功能:
$client_id = $this->uri->segment(3);
$sess_array = array(
'cl_id' => $client_d,
'selected_client'=>TRUE,
);
$this->session->set_userdata('selected_client',$sess_array);
Second function: 第二功能:
$client_sess = $this->session->userdata('selected_client');
$client_id= $client_sess['cl_id'];
Try this i think this will give you some idea. 试试这个,我想这会给你一些想法。
function one(){
$client_id = $this->uri->segment(3);
$sess_array = array(
'cl_id' => $client_d,
'selected_client'=>TRUE,
);
$this->two($sess_array);
}
function two($id){
$client_id= $id;
}
Here is what the Model looks like: 该模型如下所示:
function getResponse($gettingresponse)
{
$enrollresponse=$gettingresponse['sendresponse'];
return $enrollresponse;
}
The Controller is as follows: 控制器如下:
public function Register()
{
$this->load->view('firstview');
$this->load->view('secondview');
if($_POST) {
$gettingresponse=array(
'sendresponse'=>$_POST['source'],
'receiverresponse'=>$_POST['destination']
);
$registration_confirm=$this->systemModel->responselogin($gettingresponse);
$resposeflag=$this->systemModel->getEmail($gettingresponse);
$data['resposeflag']=$gettingresponsevalue;
if($registration_confirm){
$this->token($data);
}
}
$this->load->view('thirdview');
}
public function token($data=array())
{
$this->load->view('firstview');
$data['resposeflag'];
$this->load->view('token',$data);
$this->load->view('thirdview');
}
The following View shows the data that has been passed between the functions of the Controller. 下图显示了在控制器功能之间传递的数据。
<?php
echo form_input(array('name'=>'source','readonly'=>'true','value'=>$resposeflag));
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.