Experts say candy corn can last around 3-6 months after the packaging is opened. This assumes the candy is left at room temperature - candy stored in a hot environment will go bad much faster. Unopened bags of candy corn can last around 9 months. That's almost long enough to get you from one Halloween to the next, assuming you buy several bags, so you have enough to share without running out.
To help preserve open bags of candy corn, transfer the candies into a sealed jar or other airtight container, and store the candy corn in a dark, cool environment such as your kitchen pantry.