Hi, Im developing a web application and I have two namespacses in my application which are admin and user. I know that I should use session bag to spereate the session in each of namespcae. Here is my code:

service.php

<?php

$di->set(
    'session',
    function () {
        $session = new \Phalcon\Session\Bag('usersession');
        $di = \Phalcon\DI::getDefault();
        $session->setDI($di);
        $session->initialize();
        return $session;
    },
    true
);

$di->set(
    'adminsession',
    function () {
        $session = new \Phalcon\Session\Bag('adminsession');
        $di = \Phalcon\DI::getDefault();
        $session->setDI($di);
        $session->initialize();
        return $session;
    },
    true
);

IndexController.php

<?php
public function indexAction()
{        
    $this->tag->setTitle('Home Page');

    // I assume there is a session set already
    if(!$this->session->has('usersession'))
    {
        $this->response->redirect('user/login');
    }

    ...

    code

}

Thanks :)