Welcome Guest, Not a member yet? Register   Sign In
changing session driver to database (modified)

(This post was last modified: 06-09-2018, 10:16 AM by richb201.)

I have a working application that uses the default session driver. Here is my config.php section:

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

I am going to move this app from my localhost to a public hoster. Since only absolute paths to the session files are supported when using the files driver I NEED to change over to use the database session driver.  I'd like to make this as painless as possible without any fancy modifications. Can someone tell me what is the minimum that I MUST do to make this work? Yes, I read the documentation. General pointers would be very helpful so I can zero in on what needs to be done. 

Another possibility is to use the files driver but to point the sess_save_path to somewhere within my application directory. But what do I do about the "absolute path" requirement then? 


NOTE: this is the actual config.php:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'cisession';
$config['sess_expiration'] = 28800;  // this is 8 hours, every 8 hours the session will be destroyed and when it does the user will be logged off
//$config['sess_expiration'] = 0;    //default to 7200  In addition to this if a user doesn't have any activity in 30 minutes, they will log off via javascript_funcs.js
$config['sess_save_path'] = APPPATH.'cache';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
proof that an old dog can learn new tricks

Create a file alongside your main index.php and use getcwd, you will get the absolute path to that directory. You should be able to work it out from there.

PS. APPPATH are a absolute path.

This is how I do it makes it very easy to do.

PHP Code:
// ./application
// ./apllication/writable

$config['sess_driver'             'files';
$config['sess_cookie_name'        'ci_session';
$config['sess_expiration'         7200;
$config['sess_save_path'          APPPATH.'writable';
$config['sess_match_ip'           FALSE;
$config['sess_time_to_update'     300;
$config['sess_regenerate_destroy' FALSE

Works for me like a charm...
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB