Where I work, cabin crew entry is controlled; which is to say that a pilot must electronically unlock the door or electronically deny entry after the correct entry code was pushed. Neither the purser nor any cabin crew could just barge into the cockpit without invitation.