如何在codeignighter中从外部PHP获取会话数据 [英] How do get session data from external PHP in codeignighter
问题描述
所以我在codeigniter中有一个控制器,我希望在同一个网站中包含一个会话但不同的文件夹(非codeigniter)
会话我会这样正常使用
So I have a controller in codeigniter, I wish to include a session that I have started within the same website but different folder (non codeigniter)
the session I would normal use like so
session_start();
$userID = $_SESSION[userid];
现在我可以在该页面的任何地方使用
now I can use
$userID
var。
我怎么也不熟悉codeigniter而且我看到我需要在autoload中包含会话,我已经完成了这个。
然后
var anywhere within that page.
how ever I am new to codeigniter and for what I have seen I need to include session in autoload, I have done this.
Then
$session_id = $this->session->userdata('userid');
我尝试过:
What I have tried:
private function getResults()
{
{
$data['emailcount'] = $score = $this->actions->getEmailCount();
$data['sentEmailCount'] = $score = $this->actions->getSentEmailCount();
$data['score'] = $score = $this->actions->getScore();
$data['percentile'] = $percentile = $this->actions->getPercentile($score);
$data['timespent'] = $this->input->get('time');
};
$adddata = array(
'uniID' => '5',
'testName' => 'Abintegro E-Tray test',
'testID' => '99999',
'total' => '20',
'userID' => '00000',
'useInPercentile' => '1',
'correct' => $score = $this->actions->getScore(),
'percent' => $score = $this->actions->getScore(),
'percentile' => $percentile = $this->actions->getPercentile($score),
'dateTaken' => date('Y-m-d H:i:s'),
'timeSpent' => $this->input->get('time'),
'userID' => $session_id = $this->session->userdata('userid');
);
$this->actions->add_record($adddata);
return $this->load->view('client/results', $data);
}
推荐答案
userID =
userID =
_SESSION [userid] ;
_SESSION[userid];
现在我可以使用
now I can use
userID
userID
var该页面内的任何地方。
我怎么也不熟悉codeigniter和for我所看到的我需要在自动加载中包含会话,我已经完成了这个。
然后
var anywhere within that page.
how ever I am new to codeigniter and for what I have seen I need to include session in autoload, I have done this.
Then
这篇关于如何在codeignighter中从外部PHP获取会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!