Fatal error: session_start() after upgrading to Codeigniter 3

15,337

Solution 1

You have not configured your sess_save_path make sure folder also chmod 700

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

The autoload session

$autoload['libraries'] = array('session');

Solution 2

you may try code as below, it works for me

// before session_start();

ini_set('session.save_handler', 'files'); 

// make sure it is writeable

ini_set('session.save_path', 'c:\temp');   

session_start();
Share:
15,337
Mitteg
Author by

Mitteg

Updated on June 14, 2022

Comments

  • Mitteg
    Mitteg almost 2 years

    I upgraded from Codeigniter 2 to 3 and now I get this error with my CAS library:

    A PHP Error was encountered
    
    Severity: Error
    
    Message: session_start() [function.session-start]: Failed to initialize storage module: user (path: C:\Windows\Temp)
    
    Filename: CAS/Client.php
    
    Line Number: 3588
    
    Backtrace:
    

    It has something to do with session, which I guess CI3.0 handles it differently from CI2.0.

    I have the following in the config.php

    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = NULL;
    $config['sess_match_ip'] = FALSE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = FALSE
    

    ;

    Any help will be highly appreciated. Thanks.

    NEW:

    I did a clean CI3.0.4 install and it seems like the problem is the CAS authentication library: https://github.com/eliasdorneles/code-igniter-cas-library

    It worked with CI 2.x, but not with CI3.0. If I just not load the CAS module, everything works fine with regard to the session (I have no problem setting sessions, etc). But once I load the CAS there is a problem with the line session_start() at the CAS/Client.php. Any ideas?