1Inside controller :
2return back()->withError('You are not logged in or Your session has expired');
3
4Inside blade file :
5 @if(Session::has('errors'))
6 toastr.error("{{Session::get('errors')->first()}}");
7 @endif
8
9It’s a “magic” method, in that any call to a method with a prefix of with will
10be added to the session as flash data. So withError() will add flash data
11under the key error; withErrors() will add flash data under the key errors;
12withSuccess() will add flash data under the key of success; and so on.