Laravel 5 losing sessions and .env configuration values in AJAX-intensive applications

前端 未结 2 2182
轮回少年
轮回少年 2021-02-20 05:35

I am using Laravel 5 (to be specific, \"laravel/framework\" version is \"v5.0.27\"), with session driver = \'file\'.

I\'m developing on Windows 7 64 bit machine.

<
2条回答
  •  -上瘾入骨i
    2021-02-20 06:01

    After two days of intensive debugging I have some workarounds which might be useful to others:

    Here is my patch for Dotenv 1.1.0 and Laravel 5.0.27 to fix .env issues: https://gist.github.com/progmars/db5b8e2331e8723dd637

    And here is my workaround patch to make session issues much less frequent (or fix them completely, if you don't write to session yourself on every request): https://gist.github.com/progmars/960b848170ff4ecd580a

    I tested them with Laravel 5.0.27 and Dotenv 1.1.0.

    Also recently recreated patches for Laravel 5.1.1 and Dotenv 1.1.1: https://gist.github.com/progmars/e750f46c8c12e21a10ea https://gist.github.com/progmars/76598c982179bc335ebb

    Make sure you add

    'metadata_update_threshold' => 1,
    

    to your config/session.php for this patch to become effective.

    All the patches should be applied to vendor folder each time it gets recreated.

    Also you might want to separate the session patch out because you update session.php just once, but the other parts of the patch should be applied to vendor folder each time it gets recreated before deployment.

    Be warned: "It works on my machine". I really hope Laravel and Dotenv developers will come up with something better, but meanwhile I can live with these fixes.

提交回复
热议问题