Codeigniter: Session recreated after page reload

Asked

Viewed 207 times

1

I have a system where a session is created for the user after their login, the problem is that each access I make to the site a new session is created and the recorded data is deleted, I set 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 ...

Send session data to record them on Chrome console, redirect 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 the 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 any time and the data entered in the login no longer exists. What would be the reason for this?

  • pq vc mixes the default php session with the CI session?

  • because the documentation says I can do so...

1 answer

0


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.