Framework: laravel_session not storing automatically in any brower's local storage

Created on 17 Oct 2016  路  5Comments  路  Source: laravel/framework

  • Laravel Version: 5.3.15
  • PHP Version: 7.0.2
  • Database Driver & Version: MySql
  • Machine: Windows 8.1
    ### Description:

When I make a login or registration request, typically the laravel_session cookie is suppose to get returned by laravel and get stored into the browser's local storage.

The project being worked on is using laravel 5.3 as the back-end and communicating with the database. Where as the front-end we're using the angular framework running on the ionic platform. The other people on the project are using iOS computers where as I am on a Windows machine. Their browsers ALL return the proper responses and the laravel_session cookie goes into their local storage by default. Where as mine does not. This makes it difficult to make proper api requests to the server and test things out on my end. We're all on the same commit and using the same code. Is there something that I may have missed on my machine that could be preventing laravel's laravel_session cookie from storing on the front-end browser by default? It get's returned in the Network Tab's response as:
"Set-Cookie=laravel_Session=a9f8eaw9foiawhefao9fia23fi2onaaan3oa2no2fno233f"
however do we need to explicitly set it in the local storage for other machines vs. iOS doing it by default?

Most helpful comment

When I make a login or registration request, typically the laravel_session cookie is suppose to get returned by laravel and get stored into the browser's local storage.

This is incorrect. Local storage and cookies are two completely different mechanisms. Local storage is something only available to Javascript afaik. You cannot return a response to the browser that then stores something in local storage.

You are looking at the wrong item in the chrome developer tools sidebar. You should be looking under the "Cookies" section.

example

All 5 comments

It should work normally, need to see how your authorization middleware are set. You say you use angular as a frontend then I assume you use the API auth right?

Please share more "technical" information about the issue.

We currently have it set up right after a fresh install of Laravel 5.3. As for the angular, we haven't even been able to get to hitting the api routes because on my machine the laravel_session cookie isn't being stored in the local_storage when receiving the browser response:

Local Storage In Application Tab

localstorage

Network Tab on login

network

This is where some of my code is at:

routes\web.php

Route::get('/', function() { return View::make('index'); // app/views/index.php });

Auth::routes();

App\Http\Kernel.php

VerifyCsrfToken and CreateFreshApiToken have been disabled based on our specific needs.

'web' => [

\App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, //\App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, //\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class ],

protected $routeMiddleware = [

'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'csrf' => \App\Http\Middleware\VerifyCsrfToken::class, ];

I've cleared my cookies, my history, my cache enabled all cookies from everywhere and even reinstalled chrome and nothing has worked.

After further testing I'm fairly certain that this is a browser issue with my machine regarding cookies and how the browser interacts with them. I'm not exactly sure what changed and when.
If I use Postman with Postman Interceptor I get all proper responses and cookies. However because I cannot use the browser to run full tests I'm kind-a at a loss. Unless I fully erase everything except windows explorer .. (shudders) and re-download all browsers all over again.

When I make a login or registration request, typically the laravel_session cookie is suppose to get returned by laravel and get stored into the browser's local storage.

This is incorrect. Local storage and cookies are two completely different mechanisms. Local storage is something only available to Javascript afaik. You cannot return a response to the browser that then stores something in local storage.

You are looking at the wrong item in the chrome developer tools sidebar. You should be looking under the "Cookies" section.

example

Closing this then since it's not a bug in the framework, please use the forums where you can find help with your problem :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fuzzyma picture Fuzzyma  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

Anahkiasen picture Anahkiasen  路  3Comments

PhiloNL picture PhiloNL  路  3Comments

gabriellimo picture gabriellimo  路  3Comments