laravel how to check if session variable is empty

user7456955 picture user7456955 · Nov 10, 2017 · Viewed 14.9k times · Source

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

Answer

Marcin Nabiałek picture Marcin Nabiałek · Nov 10, 2017

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'))