## Create Session Variables...
$this->getUser()->setAttribute('nickname', 'ashwani');
## Retrieve Session Variables...
$this->nickname = $this->getUser()->getAttribute('nickname');
## Check if session is exist return 1 else blank value...
$hasNickname = $this->getUser()->hasAttribute('nickname');
## Remove Session Variable...
$this->getUser()->getAttributeHolder()->remove('nickname');
Cheers!
Retrieve Session Variables In template:
ReplyDelete$sf_user->getAttribute('id');
In Model:
sfContext::getInstance()->getUser()->getAttribute('id');
Hi.
ReplyDeleteWhat about setting session variables in AppKernel.php.
how i verify if my sesions are started?
ReplyDeleteyou can check the session is already started by
ReplyDelete$session = new Session();
if($this->container->get('session')->isStarted())
{
if( $session->get('user') == "user" )
return $this->render('CareerBundle:Backend:home.html.twig');
else
{
return $this->render('CareerBundle:Backend:myhome.html.twig');
}
}
else { return $this->redirectToRoute('career_backend_login_check'); }