Search code examples
phplaravellaravel-5laravel-bladelaravel-session

laravel how to check if session variable is empty


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


Solution

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