CodeIgniter Forums
Cookies in Google Chrome not created from time to time [SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Cookies in Google Chrome not created from time to time [SOLVED] (/showthread.php?tid=81433)



Cookies in Google Chrome not created from time to time [SOLVED] - shuwar - 03-02-2022

Hi all,
Since few days I observed strange behaviour in Google Chrome connected with Cookies.

I have three environments:
- HTTPS://somedomain.com (release env)
- HTTP://dev.somedomain.com (development env)
- HTTP://demo.somedomain.com (development env for demo)


Example:
A. for development env. (HTTP://dev.somedomain.com and HTTP://demo.somedomain.com)
- On Monday everything works fine
- On Thursday Google Chrome removes session cookie "ci_session" (cookie disapeared) and webapp cannot regenerate it again anymore
- When I clear Google Chrome browsing data everything back to normal but the situation repeats in couple days

B. for release env. (HTTPS://somedomain.com)
- problem not exists
- even If I manualy remove session cookie "ci_session" webapp regenerate it without problems

C. for local env (HTTP://localhost)
- problem not exists
- even If I manualy remove session cookie "ci_session" webapp regenerate it without problems


My comments:
It seems that the problem exists:
- only in Google Chrome (not in Safari, Opera, Edge, Firefox)
- only for HTTP and not for HTTPS protocol
- OR/AND only for subdomain (but I am not sure if it is true)
- exits for webapp installed on the internet (hosted server)
- not exists when I run webapp localy installed on my PC development env.
- problem occured on 2 different PCs with Win10 & Chrome


Please help:
- Any ideas how to handle this issue?
- Where to search the reason?
- What I can check?
- Any suggestion can be helpful



My configuration:
- Windows 10
- newest Google Chrome
- Web app on hosting server (not local)
- PHP 7.4
- CogeIgniter 3.1.11
- config.php:
  $config['sess_driver'] = 'files';
  $config['sess_cookie_name'] = 'ci_session';
  $config['sess_expiration'] = 86400; //=24h (1h=3600)
  $config['sess_save_path'] = NULL;
  $config['sess_match_ip'] = FALSE;
  $config['sess_time_to_update'] = 300;
  $config['sess_regenerate_destroy'] = FALSE;

  $config['cookie_prefix'] = '';
  $config['cookie_domain'] = '';
  $config['cookie_path'] = '/';
  $config['cookie_secure'] = FALSE;
  $config['cookie_httponly'] = FALSE;


RE: Cookies in Google Chrome not created from time to time - shuwar - 04-26-2022

After discussion with Google help desk I can say that this is not strict problem with CI but with situation when we have at least two independed webapps on two (sub)domains: one of them is using SSL (https) and another not (http):

https://maindomain.com
http://demo.maindomain.com

The workaround is to use SSL on both domains.


RE: Cookies in Google Chrome not created from time to time [SOLVED] - InsiteFX - 04-27-2022

Please in the future when you resolve your problem add [SOLVED] to your topic title
I did it for you here so that you can see how it is done.

Thank you