CodeIgniter Forums

Full Version: Session will not persists in CI 3.1.11 with CI Rest Api, no matter what I do
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I cannot get my session to persist past the login.

I can see the session data in the sessions folder, the variables are saved. When a user logs in I am saving their user id and company id in the session.

But once I navigate to another page in my ReactJS project, and do another ajax call, the CI Rest API just returns unauthorized. The session token also changes.

I noticed this bug when I went from 3.1.10 to 3.1.11. But I am not honestly sure what is causing it and what to do.

I have spent 4 hours reading blogs and forums trying all the suggestions I could find and understand; nothing is resolving this.

$config['sess_driver'= 'files';
$config['sess_cookie_name'= 'ci_session';
$config['sess_expiration'= 7200;
$config['sess_save_path'= APPPATH . 'sessions';
$config['sess_match_ip'= FALSE;
$config['sess_time_to_update'= 300;
$config['sess_regenerate_destroy'= FALSE;

$config['cookie_prefix']    = '';
$config['cookie_domain']    = '.localhost:4011';  // running dev project on my laptop
$config['cookie_path']      = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']  = FALSE;

Yes I have sessions autoloaded.

This was all working and then it just stopped after 3.1.11.
.localhost:4011 = Not a valid domain.

Use 'localhost' (becomes .localhost), '.localhost' or NULL (becomes localhost).
(01-13-2020, 11:52 AM)jreklund Wrote: [ -> ].localhost:4011 = Not a valid domain.

Use 'localhost' (becomes .localhost), '.localhost' or NULL (becomes localhost).
Thanks, I changed this but I still have the same problem. As soon as I log in, when I try another ajax request it says I am unauthorized. By the time log in occurs, the session has regenerated 4 times on 1 single request.

Also the garbage collection never seems to happen, session files just pile up.
When finished with session data you need to do a session write close when using Ajax.