What magic phrase allowed Ali barber to enter the cave of forty theives?
There is no "magic phrase" that Ali Baba used to enter the cave of forty thieves. In the story "Ali Baba and the Forty Thieves", Ali Baba discovers the cave's entrance by chance and learns the magic words
"Open Sesame" from a passing thief.
This phrase is then used by Ali Baba to open the cave, and later by Morgiana, the clever slave girl, to thwart the thieves' plans.