Maybe try storing it in the session and seeing if that works?
https://laravel.com/docs/8.x/session#storing-data
Though I see no reason why that would not work
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone... my question is simple.
Can I use flash session data when I'm working with stateful endpoints in sanctum?
For example, user enters his phone number in the first request. in order to verify it, I want to keep his phone number in the session, just for the next request.
Actually, I have tested this in postman and it was not available in the next request. I'm afraid I may have done something wrong.
As an example, here is my controller method:
public function login(LoginRequest $request)
{
$data = $request->validated();
try {
event(new WantToLogin($data['mobile']));
} catch (Throwable $th) {
// return some error
}
$request->session()->flash('mobile', $data['mobile']);
return response()->json([
'message' => 'a token has been sent to your mobile phone'
]);
}
Please or to participate in this conversation.