Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter: share session with subdomain & sess_time_to_update

It was a lot of questions how to share CI native sessions between subdomains or domain & subdomain.

Just some of them: 1, 2, 3

Everybody says that we should define $config['cookie_domain'] like this

$config['cookie_domain']    = ".example.com";

It seems to be correct answer, but... subdomain drops data on update (the value $config['sess_time_to_update'] = 300;) on both domains. After the sess_time_to_update is expired all data get droped.

Additional info:

  • CodeIgniter ver. 2.1.4
  • Subdomain & domain use the same files (alias).
  • $config['sess_use_database'] = TRUE;
like image 693
Yevgen Avatar asked Sep 17 '13 15:09

Yevgen


1 Answers

i usually would do:

$config['sess_cookie_name']     = 'asd';
$config['sess_expiration']      = 0; //24hours -> 8640
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = 'db_table';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 3000000000;

$config['cookie_domain']    = "";
like image 87
itsme Avatar answered Oct 31 '22 18:10

itsme