问题描述
我们正在使用以下方法检查所有控制器功能的会话.
We are using the following to check session on all our controller functions.
$this->session->userdata('Admin_logged_in')
https://www.codeigniter.com/user_guide/libraries/sessions.html
但是在使用Safari浏览器的iPhone X上,它返回一个空值.没有为每个功能设置会话数组,因此用户无法登录界面.
But on iPhone X using the Safari browser, it returns an empty value. The session Array is not getting set for each function, so the user is unable to log into the interface.
这是我们尝试过的不同解决方案:
Here are different solutions we tried:
CodeIgniter 3会话无法在Safari上运行
CodeIgniter 3 Session not working on Safari
http://mydons.com/fixed-mac-os-safari-codeigniter-sessionloginauthentication-issue/
https://forum.codeigniter.com/thread-63184.html
https://github.com/bcit-ci/CodeIgniter/issues/2880
如果从该功能中删除了该会话,则用户可以登录并且该功能可以正常运行.对于我们开发的所有Codeigniter项目,都会出现此问题.
If the session is removed from the function, the user is able to log in and the function runs properly. This issue appears for all Codeigniter Projects we develop.
检查会话:
public function index()
{
if ($this->session->userdata('Admin_logged_in')) {
$session_data = $this->session->userdata('Admin_logged_in');
$id = $session_data['userId'];
$data['Headding']="Dashboard";
$this->template->load('admin_layout', 'contents', 'admin/Admin_Dashboard', $data);
} else {
redirect('Admin', 'refresh');
}
}
设置会话的位置:
$sess_array = array();
foreach ($result as $result) {
$sess_array = array(
'userId' => $result->userId,
'mobile' => $result->mobile,
'email' => $result->email,
'status' => $result->status,
'RoleID' => $ans['roleId'],
);
}
$this->session->set_userdata('Admin_logged_in', $sess_array);
推荐答案
为什么要使用 Admin_logged_in 检查并设置与 User_logged_in 的会话?再次检查会话,尤其是在设置会话的位置.
Why would you check with Admin_logged_in and set session with User_logged_in? Check your session again especially where you set your session.
我认为您使用错误的名称来检查会话.
I think you are using the wrong name to check the session.
这篇关于Safari浏览器中的codeigniter会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!