I am trying to setup a symfony session variable that I can access across all my actions/templates. This is done once the user credentials have been validated, the user authenticated but before he is redirected to his homepage.
The code looks like this:
// Authentication verified
$this->getUser()->setAuthenticated(true);
// note I am deliberately using a static value
$this->getUser()->setAttribute('userid',"4");
$this->redirect('flashcard/index');
When I attempt to get this attribute in one of my actions, like this:
$this->getUser()->getAttribute('userid')
it returns null,
I take a var_dump
like this:
var_dump($this->getUser()->getAttributeHolder()->getAll());
and it returns an empty array, which means something is not quite correct.
As a heads up, I am not using sfDoctrineGuard for login authentication, although I don't think setting session variables will have anything to do with it.
$this->getUser()->getAttribute('userid')
? – 1ed