Sets the Session.
public setSession ( Symfony\Component\HttpFoundation\Session\SessionInterface $session ) | ||
$session | Symfony\Component\HttpFoundation\Session\SessionInterface | The Session |
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $request->setSession(['user_id' => 123]);
use Symfony\Component\HttpFoundation\Request; $request = new Request(); $request->setSession(['shopping_cart' => ['item1', 'item2']]);In this example, a new Request object is created and the setSession method is called to set a session variable "shopping_cart" to an array of items. This method is a part of Symfony's HttpFoundation component, which provides many classes and features for handling HTTP requests and responses in PHP applications.
public setSession ( Symfony\Component\HttpFoundation\Session\SessionInterface $session ) | ||
$session | Symfony\Component\HttpFoundation\Session\SessionInterface | The Session |