I have heard of this a number of times when I have given lectures and people come up to me and tell me things that their grandparents used to do.
One that keeps coming up is the use of onions to ward off a cold or the flu. To prevent a cold you place a small onion in a new white cotton sock and kept it on overnight. Reports are that in the morning the sock was black having absorbed the bacteria. A friend of mine told me his grandparents used to do this.
Another anecdote is that by placing an unpeeled onion in a dish in a room where people had been sick the onion attracted the bacteria and kept it away from the other family members.
A shopkeeper placed bowls of onions around her shop to keep her staff healthy.
A friend of mine puts garlic in her socks when she feels like she is coming down with a cold. ( I put my garlic in chicken soup and eat it daily during cold season.)
So it's certainly worth a try.