Session not working in codeigniter

后端 未结 1 1458
春和景丽
春和景丽 2021-01-16 12:38

Session Not working In codeigniter

Display Below error in my screen

Our Config code

$config[\'sess_driver\'] = \'files\';
$config[\'         


        
相关标签:
1条回答
  • 2021-01-16 13:38

    The problem is with this setting

    $config['sess_save_path'] = NULL;
    

    If you want to use $config['sess_driver'] = 'files'; then you need

    $config['sess_save_path'] = 'the/absolute/path_to_your/session_files';
    

    For instance, if you want those files to be in a folder named "sessions" that is at the same level as CodeIgniter's index.php file use this.

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

    The constant FCPATH is absolute path to the folder where CI's index.php is located. Typically, this is also the root folder for public html files. FCPATH could look something like /var/www/yoursitename/ on linux or C:\Users\YourName\Documents\www\yoursitename\ on Windows.

    It is considered good security policy to put the session folder outside the "public" html files. In other words, a directory above FCPATH. In this case the "sessions" folder is at the same level as your public html files. The config would then be this.

    $config['sess_save_path'] = substr(FCPATH, 0, strpos(FCPATH, 'www/'))."sessions/");
    

    Note that the 'www/' above needs to be the same as the name of your public (root) html folder.

    Also, where ever the file is the permissions for writing to that folder need to be set correctly. Consult the documentation.

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