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

rossiluca's avatar

Expired session not redirect to Login [Laravel Jestream]

Hi, I'm using a Laravel Jestream app with Inertia.js I've a problem when the session expire and didn't redirect to login page. In the log I see this error:

local.ERROR: Trying to get property 'headers' of non-object {"exception":"[object] (ErrorException(code: 0): Trying to get property 'headers' of non-object at /Users/lucarossi/code/domtracker/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:191)
[stacktrace]

Anyone had this problem and can help me?

Thank you!

0 likes
2 replies
chaudigv's avatar

I have not yet come across such an issue. Try adding the refresh meta tag.

<meta http-equiv="refresh" content="{{ config('session.lifetime') * 60 }}">

For logged in users, after the session lifetime the page will refresh and they will be returned to the same page, however they will no longer be authorised so will be redirected however the auth middleware is configured.

For more info, check https://talltips.novate.co.uk/laravel/csrf-and-expired-login-forms

rossiluca's avatar

Unfortunately nothing changes.

I see also this errors:

local.ERROR: Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, null given
local.ERROR: Argument 1 passed to Illuminate\Cookie\Middleware\EncryptCookies::encrypt() must be an instance of Symfony\Component\HttpFoundation\Response, null given

Please or to participate in this conversation.