CodeIgniter: Session re-created after page reload

0

I have a system where a session is created for the user after login, the problem is that every access I make to the site a new session is created and the data recorded are deleted, I configured the session as autoload and the settings are :

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'nomequalquer';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

This is the login code:

$user = $this->user_model->doLogin($_POST);
if($user != false){
    $this->session->set_userdata(array('logged' => true, 'user' => $user));
    $_SESSION['sess_id'] = session_id();
    echo json_encode(array('1', $_SESSION));
}else ...

I send session data to record them on the chrome console, redirection is done here:

...
function(data, status, jqXHR){
    if(status == 'success'){
        ...
        var result = JSON.decode(data);
        //debugging
        console.log(result[1]);
        //redirecionamento
        windows.location.replace = <?php echo "'" . base_url(array('admin/usuarios')) . "'"; ?>;
        ...
    }
}
...

On page some/page I put a button that accesses the following code on the server:

$_SESSION[session_id()] = 'hello!';
var_dump($_SESSION);

You can see that the session id changes at all times and the data entered in the login no longer exists. What would be the reason for this?

    
asked by anonymous 09.12.2016 / 18:33

1 answer

0

This is the second day with this problem, the only solution I found was to use the php native library, I copied this library: Native session that makes use of it, moreover it is more appropriate to my case because it does not save the information on the user's computer.

    
09.12.2016 / 20:10