我是一个使用Codeigniter 3的应用程序,在xampp本地服务器中进行测试时,一切都很好,但是当我托管在一个服务器(实时)中时,它面临与Codeigniter会话相关的问题。当用户登录并突然执行操作时,错误unlink(/tmp/ci_session..some file path here..):operation not permitted
Filename:drivers/Session_files_driver.php
Line Number: 354
即将到来,如果刷新了,页面错误就消失了,一切都很好。任何建议表示赞赏。
检查config.php中$config['sess_save_path']
的值。使用文件驱动程序进行会话时,必须使用用于存储会话文件的文件夹的绝对路径进行设置。该文件夹必须存在,并且其权限必须正确设置-尝试0700。
为响应文件驱动程序配置的请求,在application/config/config.php
中的选项应设置如下
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'sitesess'; //can be any string you like
$config['sess_expiration'] = 0;
$config['sess_save_path'] = '/absolute/path/to/folder/for/session/files/;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 1800;
$config['sess_regenerate_destroy'] = FALSE;
有关各种选项值的详细信息,请参见config.php。
config.php中与Cookie相关的变量对于正确的Session功能也很重要。会话cookie特别使用以下选项。
$config['cookie_domain'] = '.example.com'; //for example
$config['cookie_path'] = '/'; //usually works
$config['cookie_secure'] = FALSE; //Use TRUE to set cookie via HTTPS (server must be setup for SSL), otherwise set to FALSE
存储会话文件的文件夹必须具有适当的权限和所有权。有关权限等的更多信息,请参见CodeIgniter documentation。>