Dry, sunny weather is ideal for harvesting onions and shallots. You want to wait until the leaves start to turn yellow, which is a sign that the plants are no longer putting energy into growing the bulbs. At this point, bend the leaves over to help the onions ripen a little better. Leave them like this for day or two and then pull them up, ideally on a dry, sunny day. Leave them out in the sunshine for two or three days so that the skins dry out. This will make them store better. If you end up harvesting them on a rainy day you could lay them out to dry in a sunny porch or in a greenhouse instead. Once the skins have turned nice and dry (and brown) cut the leaves off.
When it comes to storing them, it is best to hang them up so that the air can circulate around them and keep them fresh. Using a mesh bag (if you ever buy logs in netted bags, these work brilliantly!) is the easiest way although we’ve heard of people filling a pair of tights with onions and hanging them up like that. If you can’t find a way to hang them up, you can pop them in a cardboard box with holes punched in, or a harvesting rack or similar. Store them in a cool, dark airy place and they will keep for a few months.