If you have a fever, it's NOT a good idea to workout. The flu is indicative of an infection and tearing up muscle fibers in the gym with a compromised immune system is unwise. In this case, It's best to stay home, get plenty of rest, and drink lots of fluids. Let your body do its thing to recover and get healthy.
If you have the cold, it MAY be a good idea to workout depending on the severity of the cold. Of course, there is the risk of infecting others within the gym but this can be reduced by washing your hands often and avoid touching your face. If you're coughing and sneezing a lot, then do NOT go to the gym and instead workout at home. Cardio is a great exercise to perform when you have a cold because it can break up the mucus within your sinuses and clear up the lungs. I have done some light outdoor jogging when sick with the cold and have felt much better after the run.
Brian Danley, CFT
"Motivation is what gets you started. Habit is what keeps you going."