Between backyard barbecues and neverending beach days, summer is the prime time for eating alfresco. Nothing beats digging into fresh fruit salad (or biting into a big ol’ burger) with your toes in the sand and the sun on your face. But remember: Your body isn’t the only thing soaking up those golden rays. If your food is left out for too long—especially in the summer heat—it starts to spoil.

Unfortunately, perishable foods hanging out in the great outdoors can become breeding grounds for bad bacteria like E.coli and Salmonella. And nothing turns a perfect beach day into a sh*tty one like a sudden case of food poisoning.

But let’s not get ahead of ourselves. Before you swear off all picnics for the rest of time, there are a few things you should know. Follow these rules of summertime snacking and you’ll be OK.

The Golden Two-Hour Rule

As you probably guessed, the exact amount of time you can leave food out of the fridge and in the great outdoors depends on the food in question—and of course, the temperature. But according to the FDA, you should always follow the basic two-hour rule: Don’t leave anything that you would typically refrigerate out for more than two hours at room temperature. If it’s a particularly hot day—anywhere near 90 degrees Fahrenheit—make that just one hour.

Most of the bacteria you don’t want to be snacking on flourish in temperatures between 40 and 140 degrees, a thermal window (quite dramatically) dubbed “The Danger Zone.” If left to do its thing, a bacterial population can double in nearly 20 minutes. Not so appetizing.

So if you’re in doubt, avoid food that’s been sitting in the hot sun for an hour or more. (One great way to do this that doesn’t require eating very very quickly is bringing a cooler!) Common sense comes into play here too—so if you notice a new scent or a slime, keep that funky food out of your body.

Don’t Forget About the Hot Stuff

While we tend to remember that the two-hour rule applies to the food we want to keep cool, it’s easy to forget that it’s just as important to keep the hot stuff hot. According to dietitian-nutritionist Gina Hassick, MA, RD, cooked hot foods that aren’t served right away should be kept at or above 140 degrees. She suggests using warming trays, slow cookers, and chafing dishes to keep your food (literally) safe and warm. Want to make sure your food isn’t falling into “The Danger Zone?” Bring a food thermometer to keep temperature tabs on your dishes.

Hassick also notes that improper cooling of hot foods often leads to foodborne illness. “Even though the food has been safely cooked, bacteria can still be reintroduced if given the opportunity.”For quicker, more even cooling, Hassick suggests using shallow containers, plastic wrap, aluminum foil, and plastic baggies when storing leftovers.

Meat, Poultry, and Fish

Unless you’re interested in inviting an angry mob of bacteria into your body, don’t leave any of these in the sun for more than an hour—or two if at room temperature. Meat, poultry, and fish are all definitely subject to the two-hour rule—and if we’re talking barbecues, be extra cautious.

Raw meat, including poultry and shellfish, is particularly prone to bacterial growth when left out in “The Danger Zone.” Staph, E.Coli, and Campylobacter can multiply rapidly—a surefire way to get food poisoning ASAP. Keep that raw meat cool and out of the sun until it goes on the grill, wash all cutting boards and plates that touched it, and keep it away from other foods that won’t be cooked.

Cheese

According to a recent Wisconsin-based study, some cheeses can safely stay unrefrigerated (at temps 70 degrees or cooler) for about six hours. However, not all cheeses are created equal—it turns out that the rate at which a cheese will start to go bad has to do with its water content. While harder cheeses (like Parmesan, Gouda, and cheddar) can hang for multiple hours, high-moisture cheeses (like ricotta, queso blanco, and mascarpone) will spoil pretty quickly. (Yep, we’re back to the two-hour rule.) So if you’re planning a day-long beach picnic? Get that cheddar… or eat your soft cheese with some hustle.

Fresh Produce

Since they’re perishable goods, fruits and veggies should also be considered part of the two-hour—one in the sun—rule, according to the FDA. To keep them fresh for longer, don’t cut into your fruit until you’re ready to chow down. That means fruit salads might not be the best idea for a picnic on a sizzling day.

Fruit Juices

So you’re dying of thirst… but that carton of OJ has been sitting out for a few hours. Is it worth it? According to Tropicana, most of its refrigerated products shouldn’t sit out of the fridge for more than three hours. If you’re outside in the hot sun? More like one.

Wine

Unless you’re making mulled wine, hot libations don’t sound particularly appetizing. And according to VinePair, there’s a reason to keep wine chilled for as long as possible. Heat and sunlight have been known to affect the tannins of wine, so if you’ve let a bottle sit out or in a roasting car for a day, it might start to become slightly acidic and tangy. Though there’s not much research on exactly how long wine can sit in the heat, we’d highly recommend toting around your vino in a cooler.

Salads and Dressings

While leafy greens will wilt after an hour or two, crunchier veggies tend to last a little longer. If you’re looking for a salad that will keep throughout a day-long barbecue, try using crunchy vegetables—like cucumbers, broccoli, tomatoes, and onion—and top with a balsamic vinaigrette. While some dressings will spoil quickly when left out for too long, others with vinegar might hold up a bit better.

According to one study, vinegar and olive oil may have antimicrobial properties that protect against Salmonella and E.Coli. (But olive oil on its own tends to become rancid quickly at high temperatures—so consider tossing in some vinegar!) Again, that doesn’t mean leave your salad in direct sunlight all day long—just know that a dressing with a vinegar base might hold up better than a creamier variety.

The Takeaway

Though there’s some science behind how foods fare when exposed to warm air, you don’t have to be a microbiologist to stay safe. Use the basic two-hour rule, your gut (and nose!)—and when in doubt, throw it out. Don’t want to be wasteful? Pack a cooler and plan to chow down before you fall asleep in the sun.