I was trying to build an application but I faced a problem with the session data. So I downloaded a new fresh CodeIgniter project and tried to work with the session but still failed. Here's what I did:
application/config/autoload.php:
$autoload['libraries'] = array('session');
$autoload['helper'] = array('url');
application/config/config.php:
$config['sess_save_path'] = 'D:\Projects\CodeIgnter-fresh\application\cache\session';
After that I created a controller called User.php
User.php
<?php
class User extends CI_Controller {
public function index() {
$this->session->set_userdata('somedata', 'somevalue');
redirect('user/dashboard', 'refresh');
}
public function dashboard() {
var_dump($this->session->userdata);
}
}
The controller contains two simple methods. The index method sets some user data and after that redirects to the other method, which dumps the userdata. Unfortunately here's what I see:
It seems the only data I am able to see is some CodeIgniter data, but for sure the data I am trying to set is gone. Interesting thing I noticed was that in application/cache/session folder I can see some files with my data in it. So I guess it has to be some permission problem, but I cannot figure it out. Any suggestions?
I'm using:
OS: Windows 10 Education
PHP version: 7.2.11
CodeIgniter version: 3.1.10