after so many day it's working, Does I do it.
On my .Env File:
CACHE_DRIVER=array
QUEUE_DRIVER=array
On my config \session.php File:
'driver' => env('SESSION_DRIVER', 'cookie'),
'lifetime' => 120,
'expire_on_close' => true,
'cookie' => 'XSRF-TOKEN',
'domain' => env('SESSION_DOMAIN', "!!!!!-- IMPORTANT PUT YOUR DOMAIN NAME HERE---!!!!!"),
1- Added this on my view/layout template as a head
<meta name="csrf-token" content="{{ csrf_token() }}">
2- After, in the same layou and before post.scripts
```<script>
window.addEventListener("load", function load(event) {
window.removeEventListener("load", load, false);
$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
}, false);
</script>```
define header for my ajax request in all pages.
- Add this on handler
if ($e instanceof TokenMismatchException) {
return redirect()->route('login')->withErrors(['message', 'Session expired, please Login again.']);
}
- add
<input type="hidden" id="_token" name="_token" value="{{ csrf_token() }}">
as a hidden file to all my forms or at less one time for a blade if using ajax.
- send
data: {
_token: $("#_token").val()
},
to all your AJAX CALL except GET.
good look :).