Laravel - Session - Determining If An Item Exists In The Session

To determine if an item is present in the session, you may use the has method. The has method returns true if the item is present and is not null:

    
    if ($request->session()->has('users')) {
        //
    }
	

To determine if an item is present in the session, even if its value is null, you may use the exists method:

    
    if ($request->session()->exists('users')) {
        //
    }
	

To determine if an item is not present in the session, you may use the missing method. The missing method returns true if the item is null or if the item is not present:

    
    if ($request->session()->missing('users')) {
        //
    }