codeigniter sess_driver and path

2020-05-29 05:45发布

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

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

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.

UPDATE

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?

1条回答
家丑人穷心不美
2楼-- · 2020-05-29 06:18

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

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;

For MYSQL Database

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`)
);
查看更多
登录 后发表回答