Cotton does not seem to develop as much static electricity as some artificial fibers. People get shocks from walking on the rug in the house, jumping on a trampoline, or playing basketball in the gym. Certain synthetic rubber soles on shoes create a lot of static electricity. Experiment with different shoes. The reason you build up static electricity usually comes from walking on a rug with certain types of shoes, when the weather is very dry.
Static electricity is more common in the winter, because the air is often dry.
The only other solution is to anticipate the sparks. You can touch some non-conducting material, such as a wooden door, before you touch something metal. This will allow some of the electrical charges to leave your body. Grounding Another idea is to use a metal object like a key and touch other metal things first with key. This will cause the spark to fly from the key and not your finger.