hi guys,
I'm stuck with this problem, my session is still present even if i already remove it, session still showing when I click the back button, unlike INVO when you click logout and press back button it shows blank page with warning/error message
here is my code
services.php
<?php
use \Phalcon\Session\Adapter\Files as SessionAdapter;
$di->set('session', function () {
$session = new SessionAdapter();
$session->start();
session_regenerate_id();
return $session;
});
SessionController.php
<?php
class SessionController extends ControllerBase
{
public function indexAction()
{
}
/* get user from login/register form */
public function registerAction(){
$username = "testsession";
$this->_session($username);
}
/* making session to be accessable */
private function _session($usersession){
$this->session->set('auth', $usersession);
}
/* end session */
public function endAction(){
$this->session->remove('auth');
$this->forward('home/');
}
}
my Elements.php
<?php
use \Phalcon\Mvc\User\Component as Element,
\Phalcon\Tag as Tag;
/**
* Elements
*
* Helps to build UI elements for the application
*/
class Elements extends Element
{
private $_tabs = array(
'Home' => array(
'controller' => 'home',
'action' => 'index',
'any' => false
),
'Test1' => array(
'controller' => 'test1',
'action' => 'index',
'any' => false
),
'Test2' => array(
'controller' => 'test2',
'action' => 'index',
'any' => false
)
);
/**
* Builds header menu with left and right items
*
* @return string
*/
public function getTabs()
{
/* get session value in HomeController startSession method */
$auth = $this->session->get('auth');
echo $auth;
if(!empty($auth)){
$controllerName = $this->view->getControllerName();
$actionName = $this->view->getActionName();
echo'<ul class="nav navbar-nav navbar-right">';
foreach ($this->_tabs as $caption => $option){
if($option['controller'] == $controllerName && ($option['action'] == $actionName || $option['any'])){
echo'<li class="active">';
}
else{
echo'<li>';
}
echo Tag::linkTo($option['controller'].'/'.$option['action'], $caption), '</li>';
}
echo'</ul>';
echo Tag::linkTo('session/end', 'Log out');
}
else{
$controllerName = $this->view->getControllerName();
$actionName = $this->view->getActionName();
echo'<ul class="nav navbar-nav navbar-right">';
foreach ($this->_tabs as $caption => $option){
if($option['controller'] == $controllerName && ($option['action'] == $actionName || $option['any'])){
echo'<li class="active">';
}
else{
echo'<li>';
}
echo Tag::linkTo($option['controller'].'/'.$option['action'], $caption), '</li>';
}
echo'</ul>';
}
}
}