PHP sessions expire "abruptly" in Chrome on Android

Viewed 595

I've built a website, that includes a log-in system. The functionality is very simple: Once the user is logged_in, i set a $_SESSION['user_id'] key. I didn't tweak anything in the behavior of the sessions: They expire either when the browser is shutdown, or when the user logs out. Nothing special.

Everything works fine both on Chrome and Firefox on Windows 7. The weird thing is, that on Android Chrome, the sessions seem to "expire", without any clear cause. I've tried deducing some consistency in this behavior- no success. I thought maybe it happens only when i "sweep right" the Chrome app tab- but it's not it. I have no clue even, how to perform some debugging on a phone browser. Any clues, to what might be the reason? Any suggestions?

In case it's relevant: I have Android 7.0, and Chrome 61.

Edit: here is the log-in code:

public static function login($user, $remember_me)
    {
        session_regenerate_id(true);

        CSRF::getToken();
        if(isset($user->picture)){//This checks if the "User" object came from FB login, or regular login. FB object would have a property named "picture" set!
           $_SESSION['user_id'] = $user['id']; 
           $_SESSION['user_name'] = $user['name'];    
           $_SESSION['user_link'] = $user['link'];    
           $_SESSION['user_photo'] = $user->picture;    

        }else{
           $_SESSION['user_id'] = $user->id;
           $_SESSION['user_name'] = $user->name;
            $_SESSION['user_email'] = $user->email;      
        }

        if ($remember_me) {

            if ($user->rememberLogin()) {

                setcookie('remember_me', $user->remember_token, $user->expiry_timestamp, '/');

            }
        }
    }

This function gets called after FB login succeeded. I have both "regular" users and FB ones, and eventually the login process end with this login() function. As i mentioned, the problem exists only on android, not on PC.

0 Answers
Related