Support the ongoing development of →
Session Architecture
Last updated 1 year ago.

No, there is no Session Contract available yet. ##If you want to resolve a Session Store Using Ioc Container When we use Session Facade proxy it returns an instance of a SessionManager class which dynamically calls the methods on the underlying Session Store. If we take a look at the Session Store class we can see that it implements the Illuminate\Session\SessionInterface which is actually extended from the Symfony\Component\HttpFoundation\Session\SessionInterface. So, if you want to resolve a Store instance through IoC container you can inject a dependency like this:

use Symfony\Component\HttpFoundation\Session\SessionInterface as SessionContract;

Route::get('/session',function(SessionContract $session) // Injection using type hinting.
	//example put call on Store.

	//getting the stored value.
	return $session->get('name');

Of course you can use a similar approach with Controller actions. Regards,

Last updated 1 year ago.

it is safer to use


which extends the symfony interface

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

keevitaja keevitaja Joined 2 Feb 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.