Laravel 5 flash message flashes again after navigating away and using back button

前端 未结 6 1576
无人共我
无人共我 2020-12-19 05:13

In my controller im trying to redirect back with a Flash message in laravel 5. This all works great. The problem is no matter how i set it up the flash message always re-app

6条回答
  •  -上瘾入骨i
    2020-12-19 05:52

    You can show flash messages using javascript and use SessionStorage to stop repeating messages. Browser cache doesn't know if browser already shown a message, but we can use SessionStorage to check it before display.

    ... var popupId = "{{ uniqid() }}"; if(sessionStorage) { // prevent from showing if it exists in a storage (shown); if(!sessionStorage.getItem('shown-' + popupId)) { $('#flash-container').append("
    {{ session('status') }}
    "); } sessionStorage.setItem('shown-' + popupId, '1'); }

提交回复
热议问题