Marijuana seeds should be kept in a cool, dark place such as a basement or in your refrigerator. They should be in an air-tight container and must stay dry. Putting a cotton ball in with the seeds before storage can help suck up any extra moisture (this is why you often see little bits of cotton in seed breeder packs).
Heat and moisture ‘signal’ to cannabis seeds that it’s time to sprout, so as long as you keep the seeds in a dry, dark environment they can remain viable for years. I have heard cases of seeds sprouting after being in storage for 5 or even 10 years. However, you will notice that older seeds take longer to germinate than fresh seeds and a few of them may not sprout at all. As time goes on, fewer and fewer of the seeds will successfully germinate.