Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ins2718's avatar

SPA, Laravel 9 + sanctum, Session store not set on request

Hello. I'm trying to make SPA using sanctum. I did everything from the SPA part of the sanctum page in the laravel documentation. And I wrote the simplest possible login function:

Auth::attempt($email, $password);

and logout function:

Auth::guard('web')->logout();
$request->session()->invalidate(); // there will be a test error here
$request->session()->regenerateToken();

And it works well in the browser, but I can't do the test.

$user = User::factory()->create([...]);

Sanctum::actingAs($user, ['*'], 'web');
$response = $this->postJson($this->url, []);

And on the last line I get an error - "Session store not set on request."

I'm sorry for my english :( . I will be very grateful for any help.

0 likes
0 replies

Please or to participate in this conversation.