codeigniter Session in Safari browser

混江龙づ霸主 提交于 2019-12-24 02:45:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!