Being a biennial, most alliums (members of the onions family) must go through a dormant storage phase before they flower and produce seed. It takes usually two years. Garden chives and some scallions are perennial since they keep dividing and producing larger clumps and can produce seed crops every year. With leeks, they are best overwintered in cold storage and kept green although there are very hardy kinds that survive over the winter in the field at temperatures way below freezing. Some kinds of scallions (the term scallions is often used to describe an immature onion or a different species which do not produce bulbs) should also be overwintered like leeks. Again, there are some very hardy kinds that winter over well in the field. The tops of many bulb onions will die down in the summer and then the bulbs are lifted, cured and are stored over the winter in a cool and dry area wherever your cooking onions best keep. In the spring, plant the bulbs outside. They will send up flower stalks and will flower on floppy stems in early or mid summer. When the flowers are pollinated by insects (for seed purity, grow only one variety of onion), dozens of small seeds form on the flower head. Wait until the heads begin to brown (you may begin to see the black seeds exposed), cut the stalks and hang upside down in a loose (allowing the escape of moisture) paper bag or sack. The seeds will fall into the bag for next year's crop. The seeds will fall off the head for a number of days since ripening takes place over a week or more. When the seed head is completely dry roll them back and forth in your hands to dislodge remaining seed. Then screen and winnow.
There are hardy winter leeks and less resilient summer kinds. You may not know the hardiness of the leek you are hoping to save the seen of. A safe way to overwinter the leek is to dig them out of the ground and store the entire plant in a cold environment above freezing and humid enough to prevent their roots from drying out. A potato storage area or root cellar would be a safe bet. For a few roots, wash the leeks, trim the tops as if preparing to sell them at market and put a bunch in the vegetable area of your refrigerator until spring if you can spare the space.
Overwintered leeks will send up a flower stalk and produce a spherical unbel that will bloom in mid summer. Sometimes the allium stalk becomes top heavy with the large umbel of flowers or the stalk weakens at the base causing it to flop down so you may want to stake them to keep them upright. The Saint Victor Leek we have been raising seed crops of for years produces huge light lavender heads that are truly beautiful in late June and into July.
Alliums are pollinated by flying insects which spread the pollen over long distances. A seed grower can raise several kinds of alliums and maintain purity only if the alliums are of different species. Bulb onions are Allium cepa, Leeks are Allium ampeloprasum, Scallions or Green Bunching Onions are usually Allium fistulosum and Chives are Allium schoenoprasum. Insects will pollinate the flowers and leeks will cross-pollinate with other leeks. Onions are in the same family but are not the same species and do not cross with leeks. The same is true of chives and some kinds of scallions which may or may not cross with bulb onions depending on the species. To raise a pure seed crop of leeks, plant only one variety of leek or isolate your leek patches as much as possible to prevent the exchange of pollen between different varieties. Planting different varieties of the same species 50 or 100 feet apart will limit crossing but it won't eliminate it and that might be fine for the needs of the typical home gardener.
We are always trying to foil the long range pollination by insects since we don't have the ability to separate by long distances. Delaying the flowering of one variety so that it flowers only after the other finishes is one option (plant one earlier or later). Planting in blocks instead of rows and then selecting seeds from the interior of the block helps. Planting two varieties with barriers between the members of the same species; plant one variety on the east side of the house. the other on the west side. The barrier can be netting with climbing beans, a corn patch, etc. Make it a challenge for pollinators to find the other variety. Bees can roam long distances but they are efficient creatures and would rather harvest pollen and nectar from all the flowers of a certain type in the same patch. Alliums that overwinter such as scallions, bulb onions and leeks flower all about the same time and early enough that corn and climbing beans are not yet effective barriers to insect flights so it is not so easy to use these types of strategies.
There has been much said about the viability of allium seed, leeks, onions, scallions, chives, etc. Unlike many kinds of vegetable seeds, their germination may decrease substantially after a year or two. Seed viability improves if the storage conditions for where the seed is maintained is cool or cold and kept dry. Don't subject seeds to dampness and extremes in temperature especially high temperatures. Many seeds including leek and onion seed store very well once the seed is dried for storage and then placed in storage under the cold conditions of the refrigerator (40°F). Place several packets of different kinds of seed in a jar on a day when humidity levels are low, seal with the lid and just put it in the fridge.