Reputation: 8821
I am using symfony and in my actions class I handle an execute function that performs some actions. Within that function I want to save a variable to the class so that I can reference it later. Is there any way to do this without writing to a database or using global PHP POST variables?
Like, in the executeIndex function I save a variable to class scope and then later when the executeEdit function is called I can retrieve that value? Can this be done?
Upvotes: 0
Views: 1198
Reputation: 22756
As Friek said, you can use session:
// store into the session
$this->getUser()->setAttribute('my_var', $var);
// fetch var already stored in the session
$my_var = $this->getUser()->getAttribute('my_var', null);
Or you can use sfConfig
, if your variable is about configuration:
// define a setting
sfConfig::set('my_var', $var);
// Retrieve a setting
$my_var = sfConfig::get('my_var', null);
Upvotes: 3