Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Sessions Do Not Work On Live Server

Tags:

codeigniter

When open codeigniter project localhost they work properly and open in server then error of invalid path

A PHP Error was encountered

Severity: Warning

Message: mkdir(): Invalid path

Filename: drivers/Session_files_driver.php

Line Number: 117

Backtrace:

File: /Library/Server/Web/Data/Sites/garden_worx/index.php Line: 292 Function: require_once

Error 2

An uncaught Exception was encountered

Type: Exception

Message: Session: Configured save path '' is not a directory, doesn't exist or cannot be created.

Filename: /Library/Server/Web/Data/Sites/garden_worx/system/libraries/Session/drivers/Session_files_driver.php

Line Number: 119

Backtrace:

File: /Library/Server/Web/Data/Sites/garden_worx/index.php Line: 292 Function: require_once

Error 3

A PHP Error was encountered

Severity: Warning

Message: fopen(6d898f163e36616cef220426dad109225a66f74a): failed to open stream: Permission denied

Filename: drivers/Session_files_driver.php

Line Number: 156

Backtrace:

like image 606
Rahul Raval Avatar asked Dec 15 '15 05:12

Rahul Raval


3 Answers

This will be really helpful to you, it was save my day too :)

in your config.php

$config['sess_save_path'] = sys_get_temp_dir();

Similar Question session error in codeigniter?

like image 174
Edwin Wong Avatar answered Nov 02 '22 02:11

Edwin Wong


In codeigniter 3 versions you can use files or database if files, make sure you have created folder where you would like your session path set and chmod 700

I use cache folder to store files sessions

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 1440;
$config['sess_save_path'] = FCPATH . 'application/cache/sessions/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;

Auto load session in application > config > autoload

$autoload['libraries'] = array('session');

Note: Make sure all file names and class names of controllers, models, libraries have first letter upper case example filename Welcome.php and class Welcome extends CI_Controller {}.

Codeigniter doc's 2 and 3 http://www.codeigniter.com/docs

Codeigniter 3 session http://www.codeigniter.com/user_guide/libraries/sessions.html

Codeigniter 2 session: http://www.codeigniter.com/userguide2/libraries/sessions.html

You also may need to have a encryption_key on config.php

$config['encryption_key'] = 'pXeQY2733rR560MrwJy40OL4WaSGmr5A';

http://randomkeygen.com/

like image 40
Mr. ED Avatar answered Nov 02 '22 01:11

Mr. ED


Simply change this in your, application -> config -> config.php

$config['sess_save_path'] = NULL;

To

$config['sess_save_path'] = FCPATH.'ci_sessions';

It will create a Directory in your Root. Hopefully your problem will solve ...

Thanks

like image 44
Mr.Faisal Avatar answered Nov 02 '22 01:11

Mr.Faisal