Hi, I have a problem with "remember me" function. When user click remember me during login then is setup cookie in that way:
$this->cookies->set('user_id', $user->user_id, time() + 15 * 86400);
ok, next if user close browser and open again, system correctly read cookie, set to session user object:
$this->session->set('user', $user);
and redirect to main page.
I also implemented SecurityPlugin like in Invo example:
if (!$this->session->user) { //redirect to login page }
I tried to dump session in SecurityPlugin and its empty.
My index.php define session nad security plugin in that way:
$di->setShared('session', function () { $session = new \Phalcon\Session\Adapter\Files(array( 'uniqueId' => 'custom-service-id' )); $session->start(); return $session; }); $di->set( 'dispatcher', function() use ($di) { $eventsManager = $di->getShared('eventsManager'); $eventsManager->attach( 'dispatch:beforeException', new ErrorPlugin() ); $eventsManager->attach( 'dispatch:beforeDispatch', new SecurityPlugin() ); $dispatcher = new Dispatcher(); $dispatcher->setEventsManager($eventsManager); return $dispatcher; }, true );
And what happend? Infinity loop ;), user from login page is redirect to main page, from main page to login page, etc.
Any idea?