CodeIgniter session changes when using a database

An oft-requested feature has been implemented in CodeIgniter’s session class.  If you use a database to store your session info, then all user data will now be in the database, rather then an encrypted cookie.  From the subversion repository’s changelog

Updated the Sessions class so that any custom data being saved gets stored to a database rather than the session cookie (assuming you are using a database to store session data), permitting much more data to be saved.

More details available in the manual.  Please read the svn upgrading instructions, as a new field needs to be added to the database for this.

This entry was made on and filed into CodeIgniter.


Sam wrote on

That’s good.

Btw, why not separate session storage drivers like it’s done to database drivers?

This way we can get memcache sessions, file sessions etc.

Ihab wrote on

Great Work

So I don’t have to use db_session library anymore ? :D

Derek wrote on

@Sam: neat idea, I’ve never really thought about it. 

@Ihab: that’s a fine session lib, but yeah, with these additions I don’t see anything that it would offer you that isn’t available in the current CI session library.

Sam wrote on

I have a lot of ideas ;)

Too Pixel wrote on

That’s really an interesting addition. CI is becoming a real Killer framework and something says me it’s only starting… We are all waiting the end of summer ;)

John wrote on

I’ve been waiting looong and patiently for this. As much as i like using 3PD libs, it just feels better using core CI stuff. Sorry OBSession but your time is nearly up!

How many times this year am i going to have to say “you da man” Mr Allard?

chris wrote on

Good job! I was waiting for something like this in the CI core. This makes development in CI even faster for me. :)

Franka wrote on

You guys are so good.  I love Code Igniter, and thanks so much for writing about it on your blog.  Its the easiest way to stay informed of whats new!

I’ve been using it since 1.4, and its growing so much thanks to you and everyone.

Derek wrote on

Thanks all, thrilled to keep growing this, although I can’t take credit for this addition to the Session class… that is pure Rick Ellis.

Jamie Rumbelow wrote on

Derek! Yes! Oh god yes!


jeremy wrote on

oooh.. i’ve been waiting for that for ages.

any idea how long until that makes it to a final release?

Derek wrote on

any idea how long until that makes it to a final release?

Its in the SVN now, and will make it into the next release.  I’m not sure when the next release will be though, if that’s what you’re asking.

Sam wrote on

Are there some very very special features that are kept exclusively for CI2? Say just “yes” or “not yet”, please ;)

Henrik Pejer wrote on

Just saw another gem in the SVN: new validation class.


mihailt wrote on

While i do not really see why we should store sessions in database, for someone this might be a nice option to use in low-load projects. Good job.