问题
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
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 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
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.
Checking session:
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');
}
}
Where session is set:
$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);
回答1:
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.
来源:https://stackoverflow.com/questions/57374386/codeigniter-session-in-safari-browser