I use a box that I can lock with a timer (called kitchensafe), which means I have no chance (except breaking the whole thing) to get to my cookies (in my case all kinds of sweets) after i set the timer (which i usually set after taking a few things). Really helps with exactly this type of problem. Although I had to buy another one for the office a few weeks ago... (I gained pounds during covid anyway, so it's not the be all end all.. but it helps me)