We’ve all been there: Getting ready to bake, you grab some eggs from the fridge, but then you get distracted, only to realize a few hours later that the eggs are still on the counter. It’s tempting to forge ahead or convince yourself that the shell somehow makes eggs impervious to quick spoilage. But the question of how long eggs can sit out has just as strict an answer as a mayonnaise-laden potato salad in the hot sun. Bottom line: In the U.S., eggs should be kept in the refrigerator and used within one to two hours after being taken out.

As eggs warm, they can enter the food danger zone where bacteria thrive, between 40°F and 140°F. This food safety mistake can be avoided by using them within two hours, or within one hour if the ambient temperature is 90° or above. The exception to this is farm-fresh eggs that have not been washed and previously refrigerated. These eggs can sit on the counter for several weeks. Refrigerated eggs last longer, about one month for raw eggs in the shell and up to four days out of the shell.

When I find myself with eggs nearing their expiration date, I save them from becoming food waste by cooking or freezing them. A batch of hard-boiled eggs lasts in the fridge for up to a week and makes a satisfying, quick snack. Alternatively, you can freeze eggs, raw (out of the shell) or cooked to use another time.

Why Grocery Store Eggs Should Be Refrigerated

To lower the risk of salmonella and cross-contamination, the U.S. Food and Drug Administration requires egg farmers to thoroughly wash, dry, sanitize and refrigerate eggs before they’re sent to stores and sold. While this process removes potential salmonella, it also removes the egg’s natural protective coating, called the cuticle or bloom. Because eggshells are slightly porous, refrigerating them prevents any new bacteria from growing and permeating the egg.

Once eggs have been refrigerated, it’s important to keep them refrigerated. According to the U.S. Department of Agriculture (USDA), when a cold egg sits at room temperature and begins to sweat, that condensation can start to breed salmonella and expose the egg to contamination.

When It’s OK to Leave Eggs on the Counter

It’s OK to leave eggs on the counter if you have purchased them from a farm and they have not yet been washed. If you want to bake with room-temperature eggs, 30 minutes at room temperature should be enough time to warm them up, or you can lower them into a glass of warm water for 5 to 10 minutes, then pat them dry.

If you have traveled abroad, you may have noticed eggs are not refrigerated in Europe because they take a different approach to combating salmonella and do not wash eggs before selling them. Before using them (or with farm-fresh eggs in the U.S.), it’s important to properly wash fresh eggs right before use to remove any dirt that could otherwise end up in your food.

How to Store Eggs

To store your eggs the right way, place them in a cold area of the refrigerator, such as the bottom shelf or toward the back where the temperature will consistently be below 40°. Keep them in their carton or transfer them to a similarly shaped storage container to prevent damage or cracking before use. If you have a built-in egg holder in the door of your fridge, as cute as it is, don’t place your eggs there because the rush of warm air every time you open the refrigerator can cause them to spoil faster.

How to Check Whether Eggs Are Safe to Eat

When considering whether eggs are safe to eat, the first step is to inspect the shells for cracks or damage, which is a big egg spoilage sign. Even if they seemed intact when you bought them, take a second look before use to ensure they didn’t crack in transit. If eggs have reached their expiration date, try the float test, which is an easy way to tell if an egg is bad. Just carefully lower an egg into a glass of water. If it sinks, the egg is still good, but if it floats, it should be discarded.

Finally, settle on how you are going to cook your eggs. The whites should be fully cooked for scrambled, poached and fried eggs, while egg casseroles and quiche recipes should reach an internal temperature of 160°. It’s not safe to eat raw eggs, according to the Centers for Disease Control and Prevention (CDC), as they can cause food poisoning and, yes, that includes raw cookie dough.