Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Sharing session variables in views #15062

Closed
RemiCollin opened this issue Aug 26, 2016 · 4 comments
Closed

[5.3] Sharing session variables in views #15062

RemiCollin opened this issue Aug 26, 2016 · 4 comments

Comments

@RemiCollin
Copy link

RemiCollin commented Aug 26, 2016

From 5.3 upgrade, it seems impossible to share session variables in views anymore, like in 5.2.

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        View::share('key', session()->get('key'));
    }
    ...
}

Is there any knew workaround to this ?

@mreschke
Copy link

I didn't think session() was even available at the Provider boot() level since laravel 4 ??? I remember it was in L4, but in L5 they changed session to middleware which is definitely NOT ready at a provider level.

@mreschke
Copy link

In L5.2 session wasn't available until routes or controller __construct. Not at provider level. And now in L5.3 its actually NOT even available at the routes or controller __construct level either. See #15072 for that

@GrahamCampbell
Copy link
Member

You can use a middleware to do this. :)

@RishabSwift
Copy link

@GrahamCampbell can you please explain how one would do so with a middleware? Stuck on the same boat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants