douxuanou2787
2018-11-06 11:52 阅读 140
已采纳

在session.save_path Codeigniter中使用模式格式

I'm facing a problem using the session library in Codeigniter. On this page it specifically says

To be more specific, it doesn’t support PHP’s directory level and mode formats used in session.save_path, and it has most of the options hard-coded for safety. Instead, only absolute paths are supported for $config['sess_save_path'].

Now what I want is to create session files with permissions 777. I've set the session_save_path in php.ini to 0;0777;/home/sessions/. This is overwritten by the local value by Codeigniter to /home/sessions. How can I force Codeigniter to create these session files with 777 permissions, as it doesn't support this in the config file.

Please don't mind about the 777 permissions on session files.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    doulouli8686 doulouli8686 2018-11-08 14:35

    About changing the default dir permissions which ic 0700 by default, i don't recommend this at all cause you'll have to change the core system files which is a very bad practice but if you must have a look at Session_files_driver.php and change mkdir($save_path, 0700, TRUE) to mkdir($save_path, 0777, TRUE) if you must and if it doesn't exist already with 0777 permission... btw, i think its way better to use db to store sessions.

    点赞 评论 复制链接分享
  • drpp5680 drpp5680 2018-11-15 04:59

    Changing some config setting you can save your session as per your set location

    $config['sess_driver'] = 'files';
    $config['sess_cookie_name'] = 'ci_session';
    $config['sess_expiration'] = 7200;
    $config['sess_save_path'] = BASEPATH . 'sessions/';
    $config['sess_match_ip'] = TRUE;
    $config['sess_time_to_update'] = 300;
    $config['sess_regenerate_destroy'] = TRUE;
    

    in $config['sess_save_path'] mention your path where you want to store your session file.

    点赞 评论 复制链接分享

相关推荐