• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter session issue


When a user is logged in, the session is created using the session helper / class in codeigniter. However, if i hit refresh or just browsing the site after awhile, i just get logged out? anyone know why this happens?

$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

1) Check and make sure you are using the correct ci_session table.
2) Check your server's time.
3) Raise the sess_time_to_update.
4) try turning off sess_match_useragent.

[eluser]Reneesh T K[/eluser]

I have a codeigniter site with a shopping cart and it is using database to store session values. But the session is going out when I add hundreds of products in it.

I have spent two days checking about it and finally find out the issue in it. It was failing to unserialize the session data stored in the ci_sessions table in the field 'user_data'.

After checking sometime I found that the field(user_data) is failing to store all serialized data in it. So when unserializing it is failing.

So I have changed the field type of 'user_data' from 'text' to 'longtext' and now it is able to store more data and my problem fixed. Now the session is not breaking.

Thats because you went over the text limit so mysql just truncated it!

I do not think that you need the longtext, change it to mediumtext.
-- ------------------------------------------------------------------------

-- Table structure for CodeIgniter ci_sessions.
DROP TABLE IF EXISTS `ci_sessions`;

  `session_id`    varchar(40)           DEFAULT '0' NOT NULL,
  `ip_address`    varchar(16)           DEFAULT '0' NOT NULL,
  `user_agent`    varchar(120)                      NOT NULL,
  `last_activity` int(10)      unsigned DEFAULT 0   NOT NULL,
  `user_data`     text,
  PRIMARY KEY (`session_id`),
  KEY `last_activity_idx` (`last_activity`)

-- ------------------------------------------------------------------------
--  `user_data` text,       COMMENT - maximum length of 65535 characters.
--  `user_data` mediumtext, COMMENT - maximum length of 16777215 characters.
--  `user_data` longtext,   COMMENT - maximum length of 4294967295 characters.
-- ------------------------------------------------------------------------

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.