CodeIgniter Forums

Full Version: codeigniter session expires frequently
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm new to this forum..

I have problem with the codeigniter1.7.2 session...

these are my session settings in config file..

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

what my problem is even though i'm browsing the site.. user sessions expires unexpectedly irrespective of the time mentioned in the config settings.

i'm using database session to store user data..
how to fix this issue...

El Forum

The 2 lines with comments are what controls the session timings, but the session library updates with a new session_id every 5 minutes.

$config[‘sess_cookie_name’]      = ‘ci_session’;
$config[‘sess_expiration’]      = 7200;            // change this using seconds.
$config[‘sess_encrypt_cookie’]  = FALSE;
$config[‘sess_use_database’]    = TRUE;
$config[‘sess_table_name’]      = ‘edu_sessions’;
$config[‘sess_match_ip’]        = FALSE;
$config[‘sess_match_useragent’] = TRUE;
$config[‘sess_time_to_update’]  = 300;            // and this one


El Forum

thank you for the post...

we can extend the session time using this setting $config[‘sess_expiration’] = 7200; .

thats fine......

if the user is ideal for some time then session expires automatically....

But what my problem is even though i'm browsing the site session expires unexpectedly.

El Forum

Well I would check to make sure that your server time is set correct, this can cause all kinds of session problems if the server time is not set correctly.


El Forum

It may be the reason i have to check it but
i have this problem on my local system(localhost) also......

i found in one post that setting the

$config['time_reference'] to GMT will fix the problem but not worked for me......

El Forum

[eluser]Julio Fagundes[/eluser]
This happens to me too.
CI Session dont update the time of expiration when the user refreshes the page etc...
Is a countdown after session start.

But we can extend the class Session.

El Forum

hi Julio Fagundes,

Did you find any solution to this.
The problem remains same for me.....
i cant find any solution to this. i need to use db session to maintain much data in session

El Forum

If you are using the session table form the CodeIgniter User's Guide it is wrong!

Here is the correct session table, they made a change to the session table on the user_agent
-- --------------------------------------------------------------

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

-- -------------------------------------------------------------
--  `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.
Also if you are running IE make sure the cookie name doe's not have an underscore it!


El Forum

Thanks a lot. it worked..

El Forum

when i made changes to ci_sessions table it worked fine.
but now the same problem again.

Any solution for this....

help me i have to fix it...