laravel how to check if session variable is empty
15,812
Solution 1
You can use
@elseif (session()->has('package_id'))
to verify if it's in session or in case it might be in session but also set to null, you can use:
@elseif (session()->get('package_id'))
Solution 2
Here:
$value = $request->session()->get('package_id', function () {
return 'Return this if session key does not exist';
});
Related videos on Youtube
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
How can I check if this session is empty, here example
@elseif {{Session::get('package_id')}}=null @include('index.customer.customerpackage')
and how to check if {{Session::get('package_id')}}=1 then Free else Paid
-
u_mulder over 6 yearsIt's better to prepare a variable in a controller.
-
-
Chuck Le Butt over 4 yearsWhy not just use
@elseif (session('package_id'))
?