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->isStarted() doesn't work

hi,

the code below doesn't work, because " $session->start();" is called at any time.

        $this->_di->set(
            'session',
            function(){
                $session = new PhSession();
                if (!$session->isStarted() ){
                    $session->start();
                }
                return $session;
            }
        );

why?

php 5.5 phalcon 1.3.2

thanks for help.

sorry for my english



98.9k

the code below doesn't work, because " $session->start();" is called at any time.

You mean $session->start() is called always or is never called?

Also you have to register this service as 'shared':

$this->_di->set('session', function(){
    //...
}, true);
edited Aug '14

always.

if (!$session->isStarted() ){... returns false always.

I got the message that the session has already been started.

but, I'll try your code.

Thanks