We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Session won't start

Hi, I can't get my session to start.

I'm having this piece of code in my services.php config file :

    $di->set('session', function() {

        $session = new Phalcon\Session\Adapter\Files();
        return $session;

In my logging function I'm setting a session variable like that :

    $this->session->set('auth', array(

        'id' => $user->ID,
        'name' => $user->Firstname . " " . $user->Lastname,
        'roleID' => $role->ID,
        'role' => $role->RoleName,
        'module' => $userModule

And in my security class, I do this :

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

When I login, I'm redirect to the main page, but when I click on a new link, it's like I'm not logged in. It returns me to the login page.

This happen since I upgrade to phalcon 1.3.1 form 1.2.4.

My login scheme is base on INVO example, it was working fine before I upgrade.

Thank you !

try to set session service as shared

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


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


Hi !

Nope. Doesn't works. :(


so, check if it works if you add at the begining of index.php


will then your application work?


Same, result.


I just find out this post in github :


I'm will give it a try.

edited Apr '14

Did you inject the DI into your security class ?

Edit : Use var_dump($_SESSION); die(); in your securiy class to know if you have somes sessions added.


The session start, it just don't hold on. When I click on a link, it return me to the login page. The solution is there : https://github.com/phalcon/cphalcon/issues/2241