会话在Codeigniter中不起作用 [英] Session not working in codeigniter

查看:63
本文介绍了会话在Codeigniter中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会话在codeigniter中不起作用

Session Not working In codeigniter

在屏幕上显示以下错误

我们的配置代码

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;


推荐答案

此设置有问题

$config['sess_save_path'] = NULL;

如果要使用 $ config ['sess_driver'] ='files '; ,那么您需要

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

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

例如,如果您希望这些文件位于名为 sessions的文件夹中与CodeIgniter的 index.php 文件处于同一级别。

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/';

常量 FCPATH 是指向CI的 index.php 所在的文件夹。通常,这也是公共html文件的根文件夹。在Linux上, FCPATH 可能类似于 / var / www / yoursitename / C:\ Windows用户\您的名称\文档\www\您的站点名称\ 在Windows上。

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.

将会话文件夹放在公共 html文件之外被认为是很好的安全策略。换句话说,位于 FCPATH 之上的目录。在这种情况下,会话文件夹与公共html文件处于同一级别。

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/");

请注意,上述'www /'需要与公用(根)html文件夹的名称相同。

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.

这篇关于会话在Codeigniter中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆