简体   繁体   English

如何通过使用会话将数据从一个功能传递到Codeigniter中的另一个功能?

[英]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.

相关问题 如何在Codeigniter中将变量从一个函数传递给另一个函数 - how to pass variable from one function to another function in codeigniter 如何将数组值从一个函数传递到另一个函数,并使用Codeigniter将其发送以查看页面? - How to pass the array value from one function to another function and send it to view the page using Codeigniter? 如何在Codeigniter中将数组从一个函数传递给另一个函数 - How to pass an array from one function to another in codeigniter CodeIgniter:如何将值从特定函数传递给另一个函数 - CodeIgniter: how to pass values from a specific function to another one 如何将数据从一个视图页面传递到codeigniter中的另一个视图? - how to pass the data from one view page to another view in codeigniter? 如何使用会话将值从一个php页面传递到另一个 - how to pass value from one php page to another using session 如何使用CodeIgniter将会话数据合并到函数中? - How to merge session data into a function using CodeIgniter? 我想将变量从一个函数传递给Codeigniter中的另一个函数 - I want to pass variables from one function to another function in codeigniter 使用codeigniter从另一个函数调用一个函数 - Call one function from another using codeigniter 如何在一个使用Laravel的控制器中将数据从一个功能传递到另一个功能? - how to pass data from one function to another, in one controller using Laravel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM