New to symfony, I am trying to start my first session
here is my entire code situated under public/php/session.php
:
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
$session = new Session();
$session->start();
I am getting error Uncaught Error: Class 'Symfony\Component\HttpFoundation\Session\Session' not found
phpstorm gives no error, do I need to install a module ? I tried composer require session
but that does not work
I also tried the symfony doc method with handler_id: ~
in config/packages/framework.yaml
with this method, no error message but no session cookie either
and here is my controller:
class HomeController extends AbstractController {
// start session
public function index(SessionInterface $session) {
$session->set('foo', 'bar');
$session->get('foo');
}
/**
* @Route("/", name="home")
*/
public function homepage(){
return $this->render('home.html.twig');
}
}