You are trying to dump and die the name property although your condition is truthy whenever it is not set. Don't try to access name.
This is functionality that could/should be implemented in a middleware, rather in web.php
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys. I have a session variable I need to check for before each page is loaded, if it isn't loaded the user gets forced logged out and redirected.
I'm trying this on the web.php page
if(!isset(session('season')->name)){ dd(session('season')->name); return redirect('logout-force')->with(Auth::logout()); }
But getting "Trying to get property 'name' of non-object"
Am I missing something here? Is there another way I should be doing this?
You are trying to dump and die the name property although your condition is truthy whenever it is not set. Don't try to access name.
This is functionality that could/should be implemented in a middleware, rather in web.php
Please or to participate in this conversation.