Link to home
Start Free TrialLog in
Avatar of sudheer sv
sudheer sv

asked on

codeigniter session in database

i am using  codeigniter i cofigured the session using database driver but its not storing in data base

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;

created table with
CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(128) 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`)
);

any help?
Avatar of Rob
Rob
Flag of Australia image

Let's start here: https://www.codeigniter.com/user_guide/libraries/sessions.html#database-driver

Do you have all the conditions satisfied that are listed under setting up the Database driver?

Did you set a primary key on the sessions table?
Avatar of sudheer sv
sudheer sv

ASKER

i followed all the conditions specified in document.

i set the primary key also.

but it's not working
these are my config values
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;
Ok, on the client, open the browser Dev tools. Can you see that the cookie is being set? Ie "ci_session" in the application->cookies section
no,
cookie is not set to "ci_session"

below are the dev-tools applicaton->cookie section data


Name               value                                               domain                             path    expires                                  size
________
PHPSESSID      g5e4o1h03rniagi5m2935tl570      develop.evescuba.com      /      1969-12-31T23:59:59.000Z         35
Can you confirm that code igniter is running and displaying views and running findings in your controller?

Do some test controller methods and views to check this
Code igniter is running correctly, all other functionalities working fine. no issues
ok and that is your site? develop.evescuba.com?
I'm also assuming you've read and implemented https://www.codeigniter.com/user_guide/libraries/sessions.html#using-the-session-class from top to bottom?

Starting with where you initialize the Session.  Do you auto-load the sessions or manually do it in your controller with the $this->load->library('session');
?
yes, i followed the Code igniter document to implement sessions.

i am not manually loading the session with "$this->load->library('session');"

i am auto loading sessions. And  yes, it's my site "develop.evescuba.com"
please give some solution.
And what happens if you try manually loading it?

Given code ignitor is running and there's no other errors, there's something missing in the steps required to set it up.

Check your php error log and see if there's anything there eg database connection / authentication issues
I'm sorry I have to ask so many questions but without access to the server itself it really is very hard to debug without going through the steps with you
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.