18
Nov
Learn how to use Codeigniter sessions across sub domains
Think, you have multiple sub domains and you need to share sessions across all sub domains on Codeigniter (CI).
http://example.com http://subdomain1.example.com http://subdomain2.example.com
You need to edit config.php as following.
$config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 0; $config['sess_expire_on_close'] = TRUE; $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'] = 300000000; $config['cookie_prefix'] = "example_"; $config['cookie_domain'] = ".example.com"; $config['cookie_path'] = "/"; $config['cookie_secure'] = FALSE;