CodeIgniter : Session does not work in google Chrome

The browser has succesfully got a cookie once (how? when? i really can't tell. I just can tell that at a certain time, I realized that my website wasn't working anymore in chrome). Now chrome keeps showing : "This site has no cookies" in the developpment tool.

It works fine in explorer / firefox / safari, etc...

Since CI session library use cookies and all my pages use the session library, I really need to fix this.

Here is my config (database table exists, works, and normally cookie is encrypted)

$config['sess_cookie_name']     = '[mydomain]sessions';
$config['sess_expiration']      = 60*60*24*7; // one week
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']      = '[mydomain]sessions';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update']  = 300;

Here is cookie config

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "[mydomain.com]";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

When user logs in, it does :

$query = $this->db->get_where('user', array('id' => $logged_in_user_id));
$row = $query->row();
$this->session->set_userdata('user_id', $row->user_id);
redirect(base_url(), 'location');

When user logs out, it does :

$this->session->sess_destroy();
redirect(base_url(), 'location');

This is simple and i guess this is the way it should be done? any idea why it does not work in chrome but works perfectly in firefox / explorer / safari?

Try adding a dot to this line:

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

My configuration is the same and it works with Google Chrome, but I have these ones different:

$config['sess_expiration']      = 86400;
$config['sess_encrypt_cookie']  = TRUE;
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;

I hope it works :-)

CodeIgniter session class not working in Chrome, Google Groups allows you to create and participate in online forums and email- based groups with a rich experience for community conversations. Hey, I'm using CI 2.1.2. Sessions library is working well on Firefox but on Google Chrome the set session item keeps on changing. What might be the problem and possible solution? Thanks you in advance.

Normally you (well in the past I have) resolve(d) it by extending the session expiry but I see yours is already set to one week. Try making it shorter? For example:

$config['sess_expiration'] = 8600;

Alternatively, you could try turning off encrypt cookie as I've just read on the CI forums someone else has resolved the issue through this method:

$config['sess_encrypt_cookie'] = FALSE;

Hope I helped. Let me know how it goes for you :)

codeigniter session issue in chrome, I am have having this issue only in chrome but not in other browsers but we are working on the localhost and have currently not published the� bcit-ci / CodeIgniter. Watch 1.7k Star 18.1k Fork 7.9k Code. Issues 53. Session Library not working in Google Chrome using codeigniter 2.1.2 #1908.

Add ob_start() on top of session library.

ob_start();
$this->load->library('Session');

And add ob_clean() in your session destroying part

$this->load->driver('cache');
$this->session->sess_destroy();
$this->cache->clean();
ob_clean();

Session cookie is not sent, We are facing the same problem with PayU (Payment) with PHP(Code CodeIgniter) and it happens only on Chrome. All works in Mozilla. PS: I draw attention to the fact that modern browsers with basic settings may not support session cookies, and this will not work. For example, in Google Chrome, these are the options "Continue where you left off" and "Continue running background apps when Google Chrome is closed".

Go to Config And just replace this if you are using on local system :

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

Or if you are using it on server just replace it like :

$config['cookie_domain']    = 'localhost';
to
$config['cookie_domain']    = '.localhost';

hopefully it will help you.

CodeIgniter session class not working in Chrome?, And the problem with google chrome was resolved. I changed the sess_match_useragent param to false in the config.php. Note. Describe the issue My axios request is working fine on google chrome but not in firefox i have no idea why, please help Code Server has set to: header('Access-Control-Allow-Origin: *'); hea

Codeigniter sessions not working CI v 3.1.7 in chrome mobile android, Codeigniter sessions not working CI v 3.1.7 in chrome mobile android In our case, we testing on localhost and webhost and the problem� To see if Chrome's open and force quit out, follow the steps below for your operating system. Windows. Press Ctrl + Alt + Delete. Click Task manager . Under "Processes," look for "Google Chrome" or

Session Library not working in Google Chrome using codeigniter 2.1 , Sessions library is working well on Firefox but on Google Chrome the set session item keeps on changing. What might be the problem and� I believe this is a bug as I've had this issue of AltLeft + Tab not working in full-screen mode before, and it eventually fixes itself. For my current session it's not working, and I've yet to identify what solves the issue. It may be solved by a host or client restart, but I don't know.

Codeigniter session not working on android chrome � Issue #5620 , Hi, am having a problem with saving sessions on chrome android browser. The system logs a user in but it doesn't redirect to dashboard page� use this header in the controller constructor. header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); If this doesn't work better to use the native session than the CI session..

Comments
  • you have set sess_use_database to true so your session is maintained through database not by cookies
  • Thanks for the suggestion jonaypelluz. I tryed and it did not work. I left cookie_domain blank and now it works. The browser has set the domain name properly. It looks like it should be handled by the browser...?