Most seeds will store for 2-4 years if kept clean, cool, dry, and out of light. However, some seeds will badly deteriorate after about one year if not stored in an airtight container in the freezer or refrigerator. These include: onions, leeks, parsnips, celery, spinach, salsify, and hybrid supersweet corn.
For long-term storage, place seed packets or bulk quantities of seed in a large, airtight container (such as a mason jar with a 2-piece lid) and store in the refrigerator or freezer. It's very important that the container be airtight to prevent moisture from getting onto your seeds. We stretch parafilm around jar rims to ensure a tight seal, but you could also use ziploc bags as extra security - inside or outside your container. Remember to let the container come to room temperature before opening it, or else moisture will condense on the cold seeds, possibly leading to mold or rot.
Freshly harvested seeds need to dry for several weeks before being stored. Especially when freezing seeds, it is crucial that the moisture content of the seeds is very low. To speed the drying process, you can hang your seeds in mesh bags in front of a fan or (carefully!) use a food dehydrator set on low. We generally don't recommend freezing home-grown bean or corn seed, because the window of suitable moisture content is relatively narrow - too much moisture can cause the seed to crack when frozen, and too little moisture can cause corn or bean seed to become permanently dormant.
<< Pictured, a seed grower's custom built rack for drying small batches of seeds using box fans.