Laravel session is not working correctly session(['locale' => 'az']);
The above returns "az" when page loaded (session("locale"))
session(['foo' => 'bar'])
The above returns null when page loaded. What is the reason of this?
What code are you using to set session(['foo' => 'bar'])
if you consider that there is no difference between locale and foo, and az and bar then your question makes no sense
I was adding the value via API request. But session is starts in the web array in the kernel. I moved the \Illuminate\Session\Middleware\StartSession::class to $middleware. It working now
I was adding the value via API request
I moved the \Illuminate\Session\Middleware\StartSession::class to $middleware
So every API request gets some Session !🕺🕺🕺
Or, maybe you need to ask yourself why web and api get different middlewares?
If i not do that not get value of "locale" from session in exception handler for error views
Whatever API endpoint is setting the locale should not be an API endpoint; move it into the web routes.
Thank you for the information.
Api should be stateless. If you need seasons move your route to web.php
If i not do that not get value of "locale" from session in exception handler for error views. Do I have to store the active language in cookies?
Please sign in or create an account to participate in this conversation.