health – Is it legal to take intoxicants at an airport/on an airplane?

I’ll be travelling to Australia from Ireland and know that it will be a very long flight. My doctor will prescribe a dozen tablets of Xanax and Ambien. I was wondering whether it’s legal to consume this at the airport/airplane.

I ask because Ambien (zolpidem tartate) is known for it’s very strange side effects including sleepwalking, sleepeating and experiencing hallucinations.