If you open it at the gate or onboard, airline staff will confiscate your purchase, empty the liquor or perfume and throw out your candy or tobacco. Your goods will meet the same fate if you show up at your final destination and a customs agent sees that you've opened the bag or its contents.