Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter sess_driver and path

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?

like image 555
Hides Avatar asked Jun 12 '16 16:06

Hides


People also ask

How do you check session is set or not in CodeIgniter?

$this->session->set_userdata('some_name', 'some_value');

How can store session in database in CodeIgniter?

Once you have created your database table you can enable the database option in your config. php file as follows: $config['sess_use_database'] = TRUE; Once enabled, the Session class will store session data in the DB.

How do you destroy a session in ci4?

To clear the current session (for example, during a logout), you may simply use either PHP's session_destroy() function, or the library's destroy() method.


1 Answers

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`)
);
like image 136
Mr. ED Avatar answered Sep 28 '22 08:09

Mr. ED