Skip to content
Advertisement

Trying to get property ‘page’ of non-object while using session variable

I am trying to put $request in the session variable but when I try to get in the controller its showing error Trying to get property 'page' of non-object.

code below

Session::put('request', $request->all());

if ($request->page == null) {
    Session::put('key', $request->all());
}

Advertisement

Answer

The error is not from session. the error on this line if ($request->page == null).

The $request->page variable you’re trying to access is not defined.

Try to check empty condition it will check variable is isset or null as well.

if (empty($request->page)) {
}
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement