Last night I was coming home from work on the bike and it was about 45 degrees outside. My legs cramped up fairly quickly and my knees starting hurting real badly. I was wearing my work slacks since they are long enough to keep me warm and have enough slack to allow me to peddle. But the knees started popping while riding, I think due to the cramped muscles, which is something they normally do not do on the bike. By time I got home my knees were hurting really bad. I warmed up under a blanket after I got home and gave them a good stretch and relax session and they started to feel better. Today my right one is still a bit sore. I want to prevent this from happening again.

Any of you ever experience this happening because of the cold? Is there anything I can do to prevent this happening again on the colder nights like this one?