Applying Codeigniter 3 to a new domain host gives mkdir() error for session_files_drive.php

前端 未结 1 1883
感动是毒
感动是毒 2021-01-23 21:49

I have a Codeigniter framework setup that I move cross multiple domain setups as a default starting point. It gives me the below error. It is the same when I added a clean insta

相关标签:
1条回答
  • 2021-01-23 22:44

    If you use Codeigniter's /default) file session storage driver, you need to keep in mind that it only supports absolute paths for $config['sess_save_path']

    the config.php states:

    |   The location to save sessions to, driver dependent.
    |
    |   For the 'files' driver, it's a path to a writable directory.
    |   WARNING: Only absolute paths are supported!
    |
    |   For the 'database' driver, it's a table name.
    |   Please read up the manual for the format with other session drivers.
    |
    |   IMPORTANT: You are REQUIRED to set a valid save path!
    

    depending on your environment use these:

    mkdir /<path to your application directory>/sessions/
    
    chmod 0700 /<path to your application directory>/sessions/
    
    chown www-data /<path to your application directory>/sessions/
    

    or

    $config['sess_save_path'] = sys_get_temp_dir(); 
    //php function which returns the directory path used for temporary files
    

    more info on CI-sessions files driver

    P.S. have a look at Session_files_driver.php (in your system/session/driver directory). There you see their use of mkdir in line 136: if ( ! mkdir($save_path, 0700, TRUE))=>>through error if dir is not writable)

    0 讨论(0)
提交回复
热议问题