【问题标题】:Codeigniter sessions with database not working in localhost but working in server与数据库的 Codeigniter 会话不在本地主机中工作但在服务器中工作
【发布时间】:2018-04-16 09:10:42
【问题描述】:

我想在我的本地主机上的主页中获取会话信息,但我没有得到它。但是在我的服务器上获取这些信息。

在本地主机中:- enter image description here

在服务器中:-

enter image description here

我正在尝试使用以下代码:-

print_r($this->session);

【问题讨论】:

标签: php codeigniter


【解决方案1】:

您可以在 Codeigniter 中像这样简单地将数据设置为会话:

$this->load->library('session');
$this->session->set_userdata(array(
    'user_id'  => $user->uid,
    'username' => $user->username,
    'groupid'  => $user->groupid,
    'date'     => $user->date_cr,
    'serial'   => $user->serial,
    'rec_id'   => $user->rec_id,
    'status'   => TRUE
));

你可以这样得到它:

$u_rec_id = $this->session->userdata('rec_id');
$serial = $this->session->userdata('serial');

【讨论】:

  • 但是在服务器上它工作正常......为什么在 localhost 会出现这个错误
猜你喜欢
  • 2018-03-02
  • 2023-03-21
  • 2020-12-07
  • 2016-03-05
  • 2014-02-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多