I thought I would post this in case anyone else runs into the same trouble.
Running CodeIgniter 2.1.0 on MAMP (Mac OSX 10.7.2, various browsers tested including Chrome 16.0.x, Safari 5.1.2, Firefox 9.0) I couldn’t get the Session class to create cookies (either as cookies or in the DB). Lots of investigation and tweaking later, I pinpointed it to the following:
$config['cookie_secure'] = FALSE; // Cannot be TRUE in localhost or cookies are not set in $_COOKIE array
As per the comments above, setting the cookie_secure property seems to be the issue (in my case anyway). Trolling through the forums and google searches, there are various reasons why your cookies may not work correctly - this is one reason when developing locally.
Setting:
$config['global_xss_filtering'] = TRUE;
Was not the issue (there are suggestions this can cause problems).
Here are my cookie settings for reference:
$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'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
Note that ‘sess_encrypt_cookie’ is true above.
