Try not to eat when you feel upset or bored — find something else to do instead (a walk around the block or a trip to the gym are good alternatives). Many people find it's helpful to keep a diary of what they eat and when and what they are feeling. When you have to write it down, you might think twice before eating cookies. Reviewing the diary later can also help them identify the emotions they have when they overeat.
Here's something else most people probably don't know: Fidgeting is good for you. It's considered a nonexercise physical activity, and it's an important way to burn energy. You get more health benefits if, in addition to exercising, you are a more fidgety, more active person the rest of the day. This means gesturing while you're talking, tapping your foot, just moving around.