laravel-debugbar icon indicating copy to clipboard operation
laravel-debugbar copied to clipboard

debugbar not show when not start session and use cookie as session driver

Open mix5003 opened this issue 2 years ago • 4 comments

step to reproduce

  1. create fresh laravel from command composer create-project laravel/laravel debugbar-cookie
  2. install laravel debug bar composer require barryvdh/laravel-debugbar --dev
  3. disable session by edit app/Http/Kernel.php and comment these 3 lines in web middleware groups
            // \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            // \App\Http\Middleware\VerifyCsrfToken::class,
  1. run php artisan serve. and go to home page. at this step you can see in debugbar that it create new _token everytime
  2. edit .env change SESSION_DRIVER to cookie
  3. go to homepage again. you can not find any debugbar anymore. and in logs you will see something like
[2022-08-16 10:30:16] local.ERROR: Debugbar exception: Attempt to read property "cookies" on null  

i think the problem is this function always want to start session. i not sure why it should start session everytime? https://github.com/barryvdh/laravel-debugbar/blob/09dc915ae3ab0b96ae78c2bfc369fac38d0b4162/src/SymfonyHttpDriver.php#L39-L46

mix5003 avatar Aug 16 '22 10:08 mix5003

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

stale[bot] avatar Nov 02 '22 03:11 stale[bot]

I am experiencing this as well. Since the SessionMiddleware is not running, the request is never set into the session handler, and that is what is throwing the exception.

ralphschindler avatar Jun 06 '23 16:06 ralphschindler