Session logout problems

#21
[eluser]Dan Allen[/eluser]
[quote author="Dan Allen" date="1328901581"]The action of deleting the session records from the DB may have been caused by a combination of too much time on $sess_time_to_update leading to deletion of the record by the garbage collection function. The apparent random occurrence of the logging out would be explained by the random function controlling the frequency of when the garbage collection function is executed.
[/quote]


MORE ABOUT FAILURE SEQUENCE AT OUR SITE - WHY RANDOM TIMING?
Session time out was not causing the random logout. Instead, the session would just keep running, even though time had expired. That is because of the imbalanced configuration values were causing checks for expiration to fail (not logout when session time has run out).

The user logout comes when garbage collection comes by to delete expired ci_session records in the database. GC spots expired records, deletes them, knocking the user to the login screen.

The reason the timing appears random, is garbage collection (GC) runs on a schedule that includes a php rand() function. When GC is called, it runs only if rand() generates a number within a certain range.

#22
[eluser]InsiteFX[/eluser]
If you are running CI 2.1.0 then make sure that your session table is correct because they made an update to it awhile back! See below new session table.
Code:
-- ------------------------------------------------------------------------

--
-- Table structure for CodeIgniter 2.1.0 `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.
-- ------------------------------------------------------------------------

If the table is not correct it will cause logouts...

#23
[eluser]Dan Allen[/eluser]
Thanks for the heads up and taking time to reply.

It happens we are running CI 1.7.3. Will be back to this when we move to the latest version. Much appreciated.

#24
[eluser]InsiteFX[/eluser]
IE Browsers do not like the under score in the cookie name. I think MS fixed it in IE 9.

#25
[eluser]theshiftexchange[/eluser]
[quote author="chandrajatnika" date="1294815869"]I have the same problems... this is my config..
Code:
$config['sess_cookie_name']    = 'ci_session';
$config['sess_expiration']    = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']    = 'login_sessions';
$config['sess_match_ip']    = TRUE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 1800;

What in the profiler that I should see????[/quote]

Turn sess_match_ip to FALSE

I had this exact issue - and after debugging for hours (including watching the DB sessions live) I was able to work out that the IP address of some users was 'cycling', and thus destroying the session.

Also - change "ci_session" to "cisession" for the cookie name (no underscores)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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