Let's get straight to the (gross) point: have you ever gotten a cold and noticed that your poop, well, seems to get all weird? Turns out, you poop more when you have a cold, and more grossly, thanks to how your sick germs mess with your gut. Feces can actually tell you quite a lot about your health, because the body's waste production system is highly influenced by things like viruses, diet and other factors. The gastrointestinal system and the colon do reflect what's happening in the rest of your body, so don't be surprised if you notice something odd in the toilet bowl during a bout of winter illness.
There are numerous ways in which colds and flu can influence your poop. One is the body's production of mucus, though this is actually pretty rare. When you're battling a cold or the flu, your respiratory system tends to go into overdrive to produce mucus-y phlegm, because it's part of its protective healing process. Occasionally mucus can end up in your stool too, but that's not really considered normal.
More common is the incidence of diarrhea. This is considered a signal that you've got a serious virus rather than just a mild cold; sniffles aren't usually accompanied by diarrhea, but flu definitely is. Certain strains of the flu manifest themselves early through diarrhea and vomiting.
Tests on mice in 2014 found that influenza viruses can cause changes in the gut microbiome, the careful balance of bacteria and other things in our intestinal tract that helps us digest food and protects against illness. These alterations seemed to "damage" the intestinal balance of the mice, causing symptoms like nausea and, yep, diarrhea. It's not entirely clear if that's precisely what happens in humans, but it's definitely a pretty viable hypothesis.
Even if you don't have the flu, though, colds can also change the composition of your stool because of one main factor: dehydration. Colds that include fevers or sweating can induce dehydration because the body loses moisture, and that can cause constipation. When you're dehydrated, the colon uses water from your waste to try and support its hydration needs, leaving you with hard, dry stools. Yet another reason to drink lots of fluids when you're getting over a cold.
And there's another reason that poop can change composition when you're down with a cold or the flu, but it's not due to the illnesses themselves. Medications that help you deal with the symptoms of colds and flus often have side effects that cause issues for your body's waste disposal system. Pseudoephedrine, a common ingredient in cold medications, can cause diarrhea, while pain medications that don't use steroids, known as NSAIDS, are known to produce constipation. This is particularly difficult for people who already have gastrointestinal conditions like irritable bowel syndrome, because dealing with a cold or flu can make their symptoms flare up.
If you do have a cold or a strain of flu, there are certain things that should come to your notice about your poop. It shouldn't have blood in it, and constipation or diarrhea that lasts for long periods and doesn't resolve itself is an issue that you should talk to a doctor about. Make sure you're staying hydrated, look carefully at the side effects of all the medicine you might be taking to help yourself feel better, and see a doctor if your poop doesn't look right after a few days.