Support the ongoing development of Laravel.io →
Security Requests Session

Is there any good practice how to give user JWT token after provider send him back? Give it to user as cookie on redirect to home page? Put it in header? As far as I know I need javascript to save token into LocalStorage/SessionStorage.

right now i'm using

first

$currentUser = JWTAuth::parseToken()->authenticate();

$request->session()->put('user_id', $currentUser->id);

after callback

$currentUser = $request->session()->get('user_id', 'default');

$request->session()->forget('user_id');

Last updated 2 years ago.
0

will this work

return redirect('/route')->with('jwt', $jwt) 
0

Sign in to participate in this thread!

Eventy

Your banner here too?

manojbojja manojbojja Joined 27 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.