1.

Explain the session set and get methods in Symfony2.

Answer»

Symfony2 USES a SessionInterface object set and get method to get and set sessions.

Following syntax can be referred as an example:

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');

}



Discussion

No Comment Found