@leostereo it's 120 minutes and I think you want to store in the cache instead of session: https://laravel.com/docs/7.x/cache
Mar 29, 2020
2
Level 2
Session lifetime question.
Hi guys , Im learning about sessions in laravel. I declare these routes:
Route::get('session/get','SessionController@accessSessionData');
Route::get('session/set','SessionController@storeSessionData');
One to store and other to retrieve the session key. and this is the controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class SessionController extends Controller
{
public function accessSessionData(Request $request) {
$value = $request->session()->get('key');
return $value;
//
}
public function storeSessionData(Request $request) {
$value = $request->session()->put('key',date("Y-m-d H:i:s"));
//
}
}
Problem is that ... after first session->put, the stored key is never cleared. According to my .env , session lifetime is 120 (secconds I suppose).
[root@localhost api_chat]# grep SESSION .env
SESSION_DRIVER=file
SESSION_LIFETIME=120
But my key still there , allways calling at http://10.1.1.50/api_chat/public/index.php/api/session/get it returns for example: 2020-03-23 14:32:21 Shouldn`t key value be cleared autmatically after 120 seconds ?
Any thought would be wellcome. Regards. Leandro.
Please or to participate in this conversation.