0
I need to create a PHP Service to manage the Sessions of an application, someone has a practical example for this?
PS: I am a beginner! :)
0
I need to create a PHP Service to manage the Sessions of an application, someone has a practical example for this?
PS: I am a beginner! :)
0
It is not necessary to create a service to manage sessions in Symfony applications, since it already has a built-in service for this purpose, called session
.
If you want to use the session
in your controllers, just call it by service id:
$this->get('session');
... or use the method getSession()
of Symfony\Bundle\FrameworkBundle\Controller\Controller
:
$this->getSession();
If you want to create a service and inject the session into it (via the constructor), just pass this one session
in the definition of the service:
service:
class: AppBundle\Service\MyService
arguments: [ @session ]
Got it? :)
Browser other questions tagged php session symfony-2 services
You are not signed in. Login or sign up in order to post.
It worked here, thank you very much Rodrigo!
– mauricio caserta
@mauriciocaserta Boa! :)
– Rodrigo Rigotti