[eluser]Unknown[/eluser]
I came across this problem I think you are right... the browser has a different user agent.
I fiddled with session.php log messages and saw that the reason the session cookie was being destroyed is because
"The user agent criteria for sessions was not met so the session has been destroyed!
DEBUG - 2009-12-26 12:03:28 --> because Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv does not equal Mozilla/4.0 (Windows Vista 6.0) Java/1.6.0_16"
The two user agents do not match. The latter agent is the java applet and the former is the browser (as it was the browser that logged in thus creating the session cookie in the first place).
However funny thing is actually this code is only supposed to be broken into when sess_match_useragent = TRUE, as it happens I changed mine to FALSE so I'm still investigating why sess_match_useragent = TRUE instead of FALSE by the time it gets to checking them.
I decided to run a test by outputting the values that are copied into the session variables from the config array in session.php:
The log code I did was:
foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
log_message('debug', "$key = ".$this->CI->config->item($key));
}
I got:
sess_encrypt_cookie = 1
DEBUG - 2009-12-26 12:17:42 --> sess_use_database = 1
DEBUG - 2009-12-26 12:17:42 --> sess_table_name = ci_sessions
DEBUG - 2009-12-26 12:17:42 --> sess_expiration = 7200
DEBUG - 2009-12-26 12:17:42 --> sess_match_ip = 1
DEBUG - 2009-12-26 12:17:42 --> sess_match_useragent = 1
DEBUG - 2009-12-26 12:17:42 --> sess_cookie_name = ci_session
DEBUG - 2009-12-26 12:17:42 --> cookie_path = /
DEBUG - 2009-12-26 12:17:42 --> cookie_domain =
DEBUG - 2009-12-26 12:17:42 --> sess_time_to_update = 300
DEBUG - 2009-12-26 12:17:42 --> time_reference = local
DEBUG - 2009-12-26 12:17:42 --> cookie_prefix =
DEBUG - 2009-12-26 12:17:42 --> encryption_key = hhi787g78gyugcdfde34w43w546e7fiy
However, my config values were actually
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$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'] = FALSE;
$config['sess_time_to_update'] = 300;
The useragent one does not match!
I have a vague idea that either I've done something silly or there is something up with $this->CI->config->item (fetching the wrong value).
Not sure what is going on completely but I think I have a lack of time so I just took out the call that checks for user agent and that fixed my problem with a dead session when I deploy a java applet that communicates with the server.
If I get around to seeing what's wrong I'll post on here, its not impossible I have done something wrong, can't thing what at the moment.