0
Hello
I have a system developed in Laravel 5.6 that keeps missing the session
When I log in:
private $prefix = '';
public function __construct(){
$this->prefix = env('APP_NAME')."_";
}
Session::put([
$this->prefix.'login' => $login,
$this->prefix.'id' => $user->usua_id
]);
This passage $this->prefix = env('APP_NAME')."_";
is to get the system name. Why?
Because I use the same system to visualize in values in simulation and not give session conflict I do the concatenation with the environment variable .env
, then has directed to the production database and another to read data in simulation
Em produção
APP_NAME=SISTEMA
Em simulação
APP_NAME=SISTEMA_TEST
The system keeps making queries every 3 seconds in the database and it seems that after some time consulting (type 5 minutes, and I scheduled to expire the session in 24horas) it simply gives error 419
Even in pages where it is not necessary to log in he loses the session
I’m performing the configuration of my ajax like this:
$.ajaxSetup({
headers: {'x-csrf-token': $('meta[name="csrf-token"]').attr('content')}
})
$.ajax({
url: '{{ route('reader.readerList') }}',
type: 'get',
dataType: 'json',
}).done( data => {
}
In the meta of my template page is like this:
<meta name="csrf-token" content="{{ csrf_token() }}">
How can I solve this problem?
Check the 'Lifetime' of your session in config/Session.php
– JrD
It’s set for 1140, two days
– adventistaam
Well, the answer is strange, but: define your
session.php
fordatabase
instead offile
– Wallace Maxters
I won’t need to set up a database ?
– adventistaam