InterviewSolution
| 1. |
How To Set And Get Session In Symfony2? |
|
Answer» SessionInterface object set and get method is used to set and get sessions in Symfony2. public function sessionAction(SessionInterface $session) { // store an attribute for reuse during a later USER request $session->set('user_id', 5); // get the attribute set by another controller in another request $user_id = $session->get('user_id'); } SessionInterface object set and get method is used to set and get sessions in Symfony2. Below look below example: public function sessionAction(SessionInterface $session) { // store an attribute for reuse during a later user request $session->set('user_id', 5); // get the attribute set by another controller in another request $user_id = $session->get('user_id'); } |
|