Esocoder
Esocoder

Reputation: 1061

Codeigniter session not saved on production server

I have been looking around for hours to find a solution. I have a CodeIgniter project that's using sessions library. On my local ubuntu dev server it works fine, but on my production server, the CodeIgniter session doesn't seem to work. So I started digging and tried finding solutions.

My codeigniter 3.1.9 and version php7.2

So far I did try without success:

  1. To see if my sessions on my production server worked without CodeIgniter. This seemed to work, so the problem must have something to do with my CodeIgniter project.

  2. In the CodeIgniter config file, I did try database sessions as well as file storage.

  3. I Checked to see if the session directory is writeable, which it is. I even see the session files that are stored in there.

  4. I upgraded CodeIgniter to the latest release. But did not help.

  5. I tried to autoload sessions as well as loading them in the controller. But no difference.

My config file is nothing special, for testing purpose I've edited sess_save_path. But in my default config file on the dev server, it's not set at all and just works, but it does not on production server. Setting the path changes nothing.

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session'; 
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = FCPATH . 'application/sessions/';
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

I just use the standard CodeIgniter session function as I should.

Only output i get from session vars is:

__ci_last_regenerate    1534007152

I hope someone reads this and can point me in other directions so I can solve my problem.

Upvotes: 2

Views: 3103

Answers (2)

Esocoder
Esocoder

Reputation: 1061

Today i had the same problem again, after the upload, my session stopped working.

After looking again at why my session didn't work, i noticed that i forgot to set the $config['cookie_domain'] in to my online version. So after changed the url into the server version, my problem got solved.

Upvotes: 0

Vishal Bondre
Vishal Bondre

Reputation: 62

try

$config['sess_save_path'] = "". FCPATH ."application/sessions/";

or

$config['sess_save_path'] = NULL;

both will work

Upvotes: 1

Related Questions