leostereo
6 months ago
1028
2
Laravel

Session lifetime question.

Posted 6 months ago by leostereo

Hi guys , Im learning about sessions in laravel. I declare these routes:

Route::get('session/get','[email protected]');
Route::get('session/set','[email protected]');

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).

[[email protected] 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 sign in or create an account to participate in this conversation.