Come on! Everyone knows that it's so easy to jump in the cockpit in the process of opening/closing of the door. Especially on the back of a FLight Attendant. Unless it is strictly prohibited for the passengers to line up by the toilet. I've never heard about such restrictions. And I never saw them observed, in case they exist somewhere
Presumably you meant 'except in the US/EU and other like-minded places'. I usually find that I've loaded myself onto an AA flight thus can't speak more broadly but no-queuing appears to be a well-enforced rule and in fact where configuration allows a beverage cart (transversely) blocks access to galley and beyond whenever the cockpit door needs to be opened.
(On the unrelated matter of cockpit manning, I note that AA uses the best-practice of maintaining two folk up there at all times.)