Meaning: If someone tells you a secret and you keep/put it under your hat, you don't tell anyone.
For example: I'll only tell you if you promise to keep/put it under your hat.
In the US, it also means "Don't forget it"
Check my blog for more idioms! http://hrhgabrielatorrens.blogspot.com.es/search/label/IDIOMS