douxuanou2787
2018-11-06 11:52
浏览 228
已采纳

在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.

图片转代码服务由CSDN问答提供 功能建议

我在Codeigniter中使用会话库时遇到问题。 在此页上,它具体说明了

更具体地说,它不支持在session.save_path中使用的PHP的目录级别和模式格式,并且它具有为安全而硬编码的大多数选项。 相反,$ config ['sess_save_path']仅支持绝对路径。

现在我想要的是创建具有权限777的会话文件。我已设置 php.ini中的session_save_path为 0; 0777; / home / sessions / 。 Codeigniter将本地值覆盖到 / home / sessions 。 如何强制Codeigniter以777权限创建这些会话文件,因为它在配置文件中不支持此功能。

请不要介意会话文件的777权限。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 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 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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题