Website is unable to properly retrieve session inf

2019-07-20 21:34发布

问题:

I had some very simple code on a website to handle logins on the root of the site using ion_auth:

if(!$this->ion_auth->logged_in())
{
   redirect("/login");
}

That page posts to /auth/login, which is handled by ion_auth. If the login is successful, the user is redirected to the root of the site. Otherwise, they go back to /login to try again. I initially thought I'd forgotten the password, but with a series of var_dump() calls, I found that the login is successful, but the call to $this->ion_auth->logged_in() returns false anyway.

All of this is after the host upgraded to PHP 7 - the code worked before. I've tried upgrading ion_auth, but it didn't help.

回答1:

There were session related problems in early CI 3.x version, documented here and here

several session related issues were resolved in the latest versions, see the change logs

solution: update to CI 3.1.7. (latest version as writing)

Upgrading From a Previous Version