Welcome Guest, Not a member yet? Register   Sign In
Codeigniter session issue
#1

[eluser]Nikita[/eluser]
Hi,

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?

Code:
$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;
#2

[eluser]InsiteFX[/eluser]
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.
#3

[eluser]Reneesh T K[/eluser]
http://myphplibrary.blogspot.in/2012/03/...ation.html

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.

#4

[eluser]InsiteFX[/eluser]
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.
Code:
-- ------------------------------------------------------------------------

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

CREATE TABLE IF NOT 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`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;

-- ------------------------------------------------------------------------
--  `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.
-- ------------------------------------------------------------------------




Theme © iAndrew 2016 - Forum software by © MyBB