Laravel sessions regenerating on every load

后端 未结 8 2296
盖世英雄少女心
盖世英雄少女心 2021-02-18 19:05

I\'m having a lot of problems and I really can\'t seem to find a solution.

Yesterday, I finished up doing some work on a vagrant box in Laravel. When I shut down the com

8条回答
  •  自闭症患者
    2021-02-18 19:41

    I spent a whole day with the same issue (session regenerated with almost every request), and could not find anything helpful online. Posting this here in case somebody has the same issue.

    Basically the problem was that the session cookie was not set correctly due to template errors. So if you run into this, first check that the session cookie is set with every request via http headers.

    In my case I wrongly used something like this in some of my templates:

    @section('test')
    

    Some content here

    @endsection

    This is wrong!

    In Laravel 4 it needs to be @stop instead of @endsection:

    @section('test')
    

    Some content here

    @stop

    Using @endsection made the app not finish correctly, so no session cookie was set. There is no trace of anything being wrong in the logfiles however. BTW, this kind of error also leads to after-filters not being applied.

提交回复
热议问题