We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Session becomes null

I have the same issue as https://forum.phalcon.io/discussion/842/session-auth-become-null-when-i-change-url-manually where the session goes null after first time login how can I solve this?

Hey, could you paste your session code from your startup file. Its usually in index.php

Mine looks like this:

    // session
    $di->setShared('session', function() {
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        return $session;
    });  


776
edited Nov '15

I am using the same session as INVO project.

first I use :

$di->setShared('session', function () {
    $session = new SessionAdapter();        
    $session->start();

    return $session;
});

then I set the variables:

$this->session->set('auth', array(
            'id' => $user->userid,
            'name' => $user->username
        ));

then access it in acl:

$auth = $this->session->get('auth');

when I access the session in the acl the second time auth is null



776
Accepted
answer

I got the problem.

i removed $this->session->destroy(); in the Security plugin