phplaravelflash-message

Flash message shows after clicking, go back and go forward browser button


I have shown flash message once request is received from the server. If a users click go back and go forward button simultaneously... He again sees the same flash message which I think it's a bad message to the users... How can I solve this issue?


Solution

  • I have achieved this problem using follwing code

      <script>
       @if(!empty(Session::get('message')))
        var popupId = "{{ uniqid() }}";
        if(!sessionStorage.getItem('shown-' + popupId)) {
            swal({
                html:
                "{{Session::get('message')}}",
                showCloseButton: true,
                showCancelButton: false,
                showConfirmButton: false,
                animation: false,
                customClass: 'animated tada',
                focusConfirm: false,
                background: '#008eb0'
            });
        }
        sessionStorage.setItem('shown-' + popupId, '1');
        @endif
    </script>