CodeIgniter Forums

Full Version: Codeigniter sessions not working CI v 3.1.7 in chrome mobile android
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I recently discovered that my website login that uses CI v 3.1.7 and Ion Auth, doesn't work on my Android version of Chrome. It  works in my Android Firefox and in Chrome/Firefox/Edge desktop. I cannot for the life of me figure out what the difference could be. 
  • I cleared all of my browser data in mobile, still the issue persists.
  • I deleted all my session files, still nothing.
  • I renamed my sess_cookie_name
  • I made a new sessions dir
  • Session recheck timer in ion_auth is OFF (always has been)
Here is my config:


Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'fagardesigns_session';
$config['sess_expiration'] = 86400;
$config['sess_save_path'] = dirname(ROOT) . DS . '_sessions_' . DS;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;


$config['cookie_prefix'] = 'nc';
$config['cookie_domain'] = '.fagardesigns.com';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;

Using chrome dev tools and my mobile device hooked up to my laptop I was able to get the session variables as expected only on success of the ajax request (using `print_r` and network response tab of dev tools). If I then went to any other page and tried `print_r`ing the session vars they no longer existed. The session cookie `fagardesigns_session` did not change between page reloads thus CI should be pulling the session vars just fine... It is almost like they were never written.

I ran a separate test on a controller like:
Code:
class Test extends MY_Backend {
   
   public function __construct() {
       parent::__construct();
   }

   public function index() {
       //$this->load->library('session');
       $this->session->set_userdata('info1', 'someinfo1');
       $_SESSION['info2'] = 'someinfo2';
   }

   public function test() {
       echo '<pre>';
       print_r($_SESSION);
   }

}

and was able to get the session variables correctly after visiting `test/index` and then visting `test/index/test`.

What could possibly be the issue? Obviously this question is very broad, but perhaps someone has either come across this issue before, or knows some troubleshooting steps I could take that I haven't thought of.


UPDATE:

As a last resort I uploaded my entire site to 000.webhost (free webhost) and tried it out. Same version of PHP, same everything except a different base_url and database connection (obviously). And it worked on my chrome mobile. Still have no clue... beginning to think there is a cookie or something in my phone that just won't delete despite me clearing Chrome's everything.
Do you discovered anything else about the problem? We're with the same problem here using CI 3.1.4. In our case, we testing on localhost and webhost and the problem occurs only in webhost. Others facts we discover:
  • Android FF (like you said) and Safari (on iOS) works perfectly.
  • The problem doesn't happen in case of incognito mode.
  • If we clear all data from chrome in android configs > applications (not only cache, ALL data), the problem also doesn't happen.
  • And, a little bit curious but, the problem occurs even if we try to login from a smartphone that never access the page before.
It's important remember that all the problem cases happened only on the web host.

If we discover anything else about the problem, I'll let you know.
I am having this same issue and I am using CI 3.1.3 with Ion Auth. On Android Firefox login works but with Android Chrome it refuses to login. 

However Chrome on laptop works perfectly.

Please help with any suggestions.
Issue exist in v3.1.8 also.Working with incognito mode
I used my moms android phone to test and it worked fine (the only other android phone I've got access to). It seems to have something to do with the combination of my phone + my live website (not a backup website with a different host) + chrome ONLY. Strange, and the fact that I can't replicate it on other devices caused me to give up. I know it had something to do with AJAX. Made a test page with no js, and could login normally and the session would stick. The second I introduced AJAX - even if it was just a request on a separate page after the user had already been logged in - the session "restarted" i.e. cleared everything.

Strange issue.
(08-05-2018, 10:29 PM)alex.fagard Wrote: [ -> ]I used my moms android phone to test and it worked fine (the only other android phone I've got access to). It seems to have something to do with the combination of my phone + my live website (not a backup website with a different host) + chrome ONLY. Strange, and the fact that I can't replicate it on other devices caused me to give up. I know it had something to do with AJAX. Made a test page with no js, and could login normally and the session would stick. The second I introduced AJAX - even if it was just a request on a separate page after the user had already been logged in - the session "restarted" i.e. cleared everything.

Strange issue.

This is a very bad issue from Chrome when used in "Lite Mode". Lite mode reduces bandwidth consumption but it lose php session variable. If you disable Chrome Lite Mode, this problem is solved!