laravel/framework — pull request #397 by illuminaux (2013-02-21 08:21:12+00:00)
Title: [Proposal] Fetch session manager from application container.

Registering the `SessionManager` with the application container allows developers to easily change the drivers or provide their own `SessionManager` implementation altogether.

My use case for this proposal is an App on Facebook. It needs some sort of persistent state but cannot rely on cookies being set/send back because of some major browsers' default policy on third-party cookies.

I would like to rely on the framework's various cache store implementations (e.g. `apc`, `memcached`) but need to provide a modified `CacheDrivenStore` driver which isn't possible as it is a **hard-coded dependency** in the current `SessionManager`.

With the proposed changes I'd be able to do something along the lines of:

// class CustomServiceProvider
function register()
{
$manager = $this->app['session.manager'];
$manager->extend('apc', function($app)
{
// Return a custom cache driven session driver
return new CustomCacheDrivenStore($this->app['cache']->driver($driver));
});
}