'How can I persist Laravel session data using Inertia Vue?
I'm having trouble updating session values using Inertia.js. The behavior I was expecting was that the redirect to 'Home' would happen only once. Once the session gets cleared, any page reloads would go into 'Nok.' But that's not what happens. The $request->session()->forget(['ok']);
is not persisted and always falls back to 'Home'. How do I get the expected behavior?
Example
public function home(Request $request)
{
$ok = $request->getSession()->get('ok', null);
if ($ok) {
$request->session()->forget(['ok']);
return Inertia::render('Home', [...]);
} else {
return Inertia::render('Nok', [...]);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|