Google News
logo
Symfony - Interview Questions
How to create and remove sessions in Symfony Framework?
In Symfony Session, the class is used to work with sessions. This class can perform all functions of native PHP sessions. Below is an example of creating and removing sessions in Symfony.
 
* Creating Session in Symfony
$session = new Session();  
$session->start();  

*
Setting Session in Symfony
$session->set('user_id', 200);  
* Getting session in Symfony
$session->get('user_id');  

*
Removing / Destroying session in Symfony
$session->remove('user_id');  
Advertisement