ini_set(): A session is active. You cannot change the session module's ini settings at this time
  • I keep getting this error when the admin is logged in, I guess this will be the case when any user is logged in.
    Detailed error message:

    A PHP Error was encountered

    Severity: Warning

    Message: ini_set(): A session is active. You cannot change the session module's ini settings at this time

    Filename: Session/Session.php

    Line Number: 316


    I guess this is a codeigniter bug which suggests adding session_start() before loading the session library $this->load->library('session');

    The cms is using session library at files fuel\modules\fuel\controllers\User.php, Reset.php, Pages.php, Login.php

    I tried adding the below fragment before the session load library

    if(function_exists(session_status)){
    if (session_status() == PHP_SESSION_NONE) {
    session_start();
    }
    }else{
    if(session_id() == '') {
    session_start();
    }
    }

    But I keep getting -
    Message:  A session had already been started - ignoring session_start()


    Could you suggest a solution for this?
    Thanks.
  • Do you have session_start somewhere else in your codebase?
  • No, I have not used session_start anywhere.. Why is the forum panel not accessible via phone!
  • Hi Admin,

    Any luck here..
  • I'm unfortunately not able to replicate this issue locally. Is this happening to you on a fresh install of FUEL?
  • I don't know, what qualifies for fresh install. Initially on the fresh install there is only one home page. I logged in to admin panel, but I guess there is not much happening on a fresh install, so there is no session related issue.
    The issues started showing up once I have added modules - custom models for data. Then the home page started showing session error that I have mentioned above.
  • Were you able to identify what custom modules seemed to be triggering the error?
  • Hi Admin,

    Extremely sorry for the delayed response, as I had some deployments lined up!

    I tried commenting each one of the modules but still not able to figure out what was causing the session error to popup.

    I tried to work-around the issue by creating a function which check whether the session is already set!

    //custom function to check if the session error is resolved
    function is_session_started()
    {
    if ( php_sapi_name() !== 'cli' ) {
    if ( version_compare(phpversion(), '5.4.0', '>=') ) {
    return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
    } else {
    return session_id() === '' ? FALSE : TRUE;
    }
    }
    return FALSE;
    }

    I added the above function in
    fuel/codeigniter/libraries/Session/Session.php end of file in the CI_Session class

    Also introduced the check on line 143
    if ( $this->is_session_started() === FALSE ) session_start();

    In the same file at line 316, I resolved or rather suppressed the error
    ini_set(): A session is active. You cannot change the session module's ini settings at this time
    by commenting out line 316
    //ini_set('session.use_trans_sid', 0);

    I am not sure if the above commented line will have any adverse effects! I would like to know if I should go ahead this way. The above mentioned actions sorted the session related issues.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!