Codeigniter: share session with subdomain & sess_time_to_update

There were many questions about how to split your own CI sessions between subdomains or domain and subdomain.

Just some of them: 1 , 2 , 3

Everyone says we should define $config['cookie_domain'] as follows

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

It seems to be the correct answer, but ... the subdomain flushes data during the update (value $config['sess_time_to_update'] = 300; ) on both domains. After sess_time_to_update expires, all data is deleted.

Additional Information:

  • CodeIgniter Ver. 2.1.4
  • The subdomain and domain use the same files (alias).
  • $ config ['sess_use_database'] = TRUE;
+4
source share
1 answer

I would usually 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'] = ""; 
+5
source

Source: https://habr.com/ru/post/886657/


All Articles