Onions are good for us, but they have no magical powers to gather germs and prevent us from getting sick, as this ancient and persistent myth holds. The notion that onions can ward off sickness goes back to the days before people knew that invisible microorganisms caused disease. During the Black Death (an epidemic of bubonic plague) in the 14th century, many people believed that onions could help protect them. They thought plague was caused by exposure to "miasma," a poisonous mist, and that strongly scented materials could absorb the dangerous vapor. The version of the myth that has cropped up more recently includes anecdotes, such as one about a farm family that came through the great influenza pandemic of 1918 unscathed as a result of putting onions in every room of the house.
You can read commentaries on the internet alleging that onions work by attracting and absorbing dangerous bacteria and viruses. This is ridiculous. Most germs aren't floating in the air waiting for an opportunity to land on us. They inhabit moist environments and become airborne only when the liquid is propelled outward – for instance, when someone sick sneezes.
Garlic has a similar reputation. It does, indeed, have significant antibiotic properties, but only when you consume it, preferably raw. When I feel a cold coming on, I eat a clove or two of mashed, raw garlic mixed with food.
Onions haven't been studied as well as garlic, but, eaten raw, they may also boost your resistance.
Bottom line: to get health benefits from onions, you have to eat them; they won't do you any good sitting across the room.
Andrew Weil, M.D.