msslgomez
1 month ago
433
28
General

Store value globally in controller

Posted 1 month ago by msslgomez

I need to save a token to then use in all methods of a specific controller, I tried putting it in session but then when I try to use it it says it's null.

This is what I have where I get the token, which does return a token value

session(['access_token' => $res_body->access_token]);

dd(session('access_token'));

But when I try to use session('access_token') in another method it returns null.

What is the best way to achieve this?

Please sign in or create an account to participate in this conversation.