jeudi 30 juin 2022

Laravel 5.4 - remember me and custom session values issue

I get project that has custom values in sessions. I use Remember me option, and every time when session is expired, new session is created (regenerated).

Now, I have problem because I need to keep all data from main session (first created) and keep values for all time that user is logged in .

Example:

if (Auth::attempt(['email' => $email, 'password' => $password], $rememberMe)) {
    $data = [
        'unread_messages'         => $message->unread_messages,
        'unread_worker_messages'  => $message->unread_worker_messages,
        'unread_poll'             => $message->unread_poll
        ];
        
        session(['num_unread_message' => $data]);
}

Now, when the session is expired after 2 hours, user will be logged, because Remember me is TRUE, but the values in Session get vanished.

I need to keep all of values in the new session that will be created after regeneration.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/1JkY6Pj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire