Codeigniter Session Issue

Session often breaks in codeigniter ??? Here is the fix !

I developed e-commerce website using php codeigniter and it is using database to store session values. But the session is lost if it has more data in it

I have spent some days checking about it and changed the third party session library , it has lots of limitations again i switched back to codeigniter default session library and trying to fix the issue finally i found out the issue in it. It was failing to unserialize the session data stored in the user_data field in ci_session table

So I have changed the field type of ‘user_data’ from ‘text’ to ‘longtext’ and now it is able to store more data in session , problem is fixed

The preferred table structure for the ci_sessions

 CREATE TABLE `ci_sessions` (
 `session_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT ‘0’,
 `ip_address` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT ‘0’,
 `user_agent` varchar(120) COLLATE utf8_unicode_ci NOT NULL,
 `last_activity` int(10) unsigned NOT NULL DEFAULT ‘0’,
 `user_data` longtext COLLATE utf8_unicode_ci,
 PRIMARY KEY (`session_id`)


This site uses Akismet to reduce spam. Learn how your comment data is processed.