benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.35k stars 1.14k forks source link

Different behavior of session handle in local versus remote server #1575

Closed ekristino closed 1 year ago

ekristino commented 1 year ago

I am integrating KCfinder file management into my project.

I put this line at login function in Auth controller as to add variable session for KCfinder: $this->session->set_userdata('KCFINDER', array('disabled' => False));

this works very well on local server. The KCfinder can read the session->userdata and hence it serves file management properly.

UNFORTUNATELY it failed when I uploaded the project to remote server. It seems ion_auth's login function at remote server cannot barely do _setuserdata from the Auth controller.

Then, I move the line into _setsession function in ion_auth_model.php.

`public function set_session($user){ $this->trigger_events('pre_set_session'); $session_data = [ 'identity' => $user->{$this->identity_column}, $this->identity_column => $user->{$this->identity_column}, 'email' => $user->email, 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id 'old_last_login' => $user->last_login, 'last_check' => time(), 'ion_auth_session_hash' => $this->config->item('session_hash', 'ion_auth') ];

    $this->session->set_userdata('KCFINDER', array('disabled' => False)); // <<<<<THIS LINE>>>>>
    $this->session->set_userdata($session_data);

    $this->trigger_events('post_set_session');

    return TRUE;
}`

The KCFinder does successfully read the session, BUT it returns array when I echo the session variable for KCFINDER
I am not sure whether this is session handle behaviour or server settings problems. Please help me to figure out the problem and solve it.

Many thanks.

benedmunds commented 1 year ago

Hey, I’ve never used KCFinder so you might get better support on the CI forums. You are setting that to an array here so it makes sense that it would return an array. Maybe try adding this to the $session_data array so you aren’t calling set_userdata multiple times, and see if that works.

ekristino commented 1 year ago

Oddly, my first approach works fine in local server,,but doesnt wok in rmote one. Thanks for reply and suggestion anyway.

benedmunds commented 1 year ago

Ah interesting, no problem!