-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Session data in service providers #7906
Comments
We cannot process support requests here. It looks like you're using it wrong. |
@swiggles i think you should make a PR for your proposal. |
@GrahamCampbell I'd say the issue is that things like this were possible in 4.x, and aren't anymore. There have been a lot of issues about this stuff, I think we shouldn't dismiss them this easily. I'll try to find out what we can do to improve the situation... |
@GrahamCampbell - The issue is that i need to access data in the session container from within the service provider. I have a package that adds items to a navigation container so all i have to do is call the service provider for that package. I can't retrieve the currently logged in user, because the session has not been started. This is because the session is started later than the service provider's boot method, in middleware The proposal is to fire an event \Event::fire('session.started'); in the session middleware so that we can listen for this event in a packages service provider or anywhere in the app that we need to. It would be more constructive for you to explain how you came to the conclusion that it looks like i'm using it wrong, rather than just dismissing the issue. Thank you |
I concur with @swiggles and @franzliedke. This is a true bug and it would be nice if it wasn't so quickly dismissed. @swiggles will you issue a PR to have this resolved? |
use redis instead of native session |
I have the same problem here, I forced to use Middleware instead of ServiceProvider, though to use ServiceProvider is more logical for dynamically configuring menu items for example. |
+100000 |
Yeah i agree! Sessions are only available within controllers and middleware. But the service provider boot method claims i could BOOTSTRAP application stuff, but without the session i can't bootstrap my application as it should, the middleware is great solution but this is only for HTTP, but what about bootstrapping when running in console? the middleware is not executed then. I need to bootstrap modules and plugins in both HTTP and console, and it requires a session. I hope this is going to be fixed so that sessions are available in Boot methods or at least in the App::booted callback. |
Hi,
In relation to this https://laracasts.com/discuss/channels/general-discussion/laravel-5-session-data-is-not-accessible-in-the-app-boot-process?page=1.
I am having the same problem, would firing a 'sessionstarted' event in the start session middleware be an option?
Thanks
Sam
The text was updated successfully, but these errors were encountered: