I am flashing a success message using session->flash() method in laravel. But when user clicks back button the message comes up again. How to fix this. My code for showing message is -
@if(Session::get('success') )
<script>
swal({
text: "{{Session::get('success')}}",
button: localMsg.ok,
}).then((isConfirm) => {
});
</script>
@elseif(Session::get('error'))
<script>
swal({
text: "{{Session::get('error')}}",
button: localMsg.ok,
}).then((isConfirm) => {
});
</script>
@endif
You should destroy session values for success and error message
@if(Session::get('success') )
<script>
swal({
text: "{{Session::get('success')}}",
button: localMsg.ok,
}).then((isConfirm) => {
});
{{ Session::forget('success'); }} //Add this line to destroy value for 'success'
</script>
@elseif(Session::get('error'))
<script>
swal({
text: "{{Session::get('error')}}",
button: localMsg.ok,
}).then((isConfirm) => {
});
{{ Session::forget('error'); }} //Add this line to destroy value for 'error'
</script>
@endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With