The cookie will always be flat if the butter has already melted before you started. Even when the recipe says softened butter, which means you should whip it with eggs and sugar, make sure it is not weepy at all. A good example should be something like the Play Dough: which can be easily bent, but can't bleed towards the foil or run all over your hands.