Corn, like all fruits and vegetables, is perishable and susceptible to spoilage. Whichever way you cook it, it's best to cook corn in a timely fashion, since corn on the cob stays fresh for only one to three days, or five to seven if refrigerated.
If the corn on the cob looks moldy or smells rancid, or if it has a slimy or mushy texture, that's a sure indication it's no longer fit to eat. On the other hand, brown kernels can usually just be cut off as long as no other signs of spoilage are present.
One of the best ways to keep corn on the cob fresh longer is to be more selective when shopping and keep your eyes peeled for any telltale markers of incipient aging. As for storage, leave the husks on, wrap the corn in plastic, and refrigerate the corn immediately to preserve the corn's fresh, sweet flavor.