codeigniter sess_driver和路径 [英] codeigniter sess_driver and path

查看:137
本文介绍了codeigniter sess_driver和路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的 codeigniter 3 网站上传到godaddy,但是我不断收到诸如 Session之类的错误消息:已配置的保存路径'C: \Windows\Temp'在PHP进程中不可写。

I am trying to upload my codeigniter 3 site to godaddy, but I keep getting errors messages such as Session: Configured save path 'C:\Windows\Temp' is not writable by the PHP process..

我遵循了此问题和codeigniter数据库驱动程序此处,但到目前为止没有任何内容。

I have followed this question and the codeigniter database driver here but so far nothing.

我在数据库中创建了一个ci_sessions表,将驱动程序设置为数据库,并将路径设置为 ci_sessions ,但随后出现致命错误。我尝试将驱动程序设置为文件,并设置了我创建的ci_sessions文件夹的路径,但找不到它,但是不确定我是否正确创建了它,我使用了 $ config ['sess_save_path'] = '{{site_path}} / application / ci_sessions';

I created a ci_sessions table in my database, set the driver to database and the path to ci_sessions but I then get a fatal error. I tried setting the driver to files and the path to a ci_sessions folder I created but it can't find it but I'm not sure I created it correctly, I used $config['sess_save_path'] = '{{site_path}}/application/ci_sessions';

有人知道我在做什么错吗?

Does anyone have any idea what I'm doing wrong? Thanks in advance.

更新

好,所以我从头开始版本的 codeigniter 3 并将驱动程序设置为数据库,并将路径设置为ci_sessions,它可以工作,但是当我使用 if(!empty($ this-> ; session-> userdata( user_id))会导致致命错误,有什么想法吗?

Ok, so I started with a fresh version of codeigniter 3 and set the driver to database and path to ci_sessions and it works, but when I use if(!empty($this->session->userdata("user_id")) it causes the fatal error, any ideas?

推荐答案

在会话保存路径上,您似乎正在尝试将其保存到文件夹

On your session save path looks like you are trying to save it to folder

在应用程序中创建一个名为ci_sessions的文件夹,将其设置为0700

create the a folder in application called ci_sessions make it 0700

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

如果需要将其放入数据库

If you need to put it into database

$config['sess_driver'] = 'database'; // Change files to database
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions'; // This will be your database table for sessions
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

对于MYSQL数据库

CREATE TABLE IF NOT EXISTS `ci_sessions` (
    `id` varchar(40) NOT NULL,
    `ip_address` varchar(45) NOT NULL,
    `timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
    `data` blob NOT NULL,
    KEY `ci_sessions_timestamp` (`timestamp`)
);

这篇关于codeigniter sess_driver和路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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