CodeIgniter Forums
codeigniter session expires frequently - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: codeigniter session expires frequently (/thread-39233.html)



codeigniter session expires frequently - El Forum - 03-05-2011

[eluser]nani[/eluser]
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...


codeigniter session expires frequently - El Forum - 03-05-2011

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

Code:
$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

InsiteFX


codeigniter session expires frequently - El Forum - 03-05-2011

[eluser]nani[/eluser]
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.


codeigniter session expires frequently - El Forum - 03-05-2011

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

InsiteFX


codeigniter session expires frequently - El Forum - 03-05-2011

[eluser]nani[/eluser]
thanks
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......


codeigniter session expires frequently - El Forum - 03-05-2011

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


codeigniter session expires frequently - El Forum - 06-03-2011

[eluser]nani[/eluser]
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


codeigniter session expires frequently - El Forum - 06-03-2011

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

InsiteFX


codeigniter session expires frequently - El Forum - 06-08-2011

[eluser]nani[/eluser]
Thanks a lot. it worked..


codeigniter session expires frequently - El Forum - 07-28-2011

[eluser]nani[/eluser]
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...