The phrase first appears in writing in Antoine Galland's Les Mille et une nuits (1704–1717) as Sésame, ouvre-toi (English, "Sesame, open!"). No earlier oral or written version of the story is known in any language.
Galland's phrase has been variously translated from the French into English as "Sesame, Open", "Open, Sesame" and "Open, O Simsim".
Open Sesame has been classified by Stith Thompson as motif element D1552.2, "Mountain opens to magic formula".
Use in the story
In the story, Ali Baba overhears the thieves saying "open sesame". His brother later cannot remember the phrase, and confuses it with the names of other grains (becoming trapped in the magic cave).
There are many theories about the origin of the phrase. Indeed, it is not certain that the word "sesame" actually refers to the sesame plant or seed.
Some older, rejected, theories include:
Sesame is a reduplication of the Hebrewšem 'name' i.e. God or a kabbalistic word representing the Talmudic šem-šamáįm ("shem-shamayim"), 'name of heaven'.
Sesame is connected to Babylonian magic practices which used sesame oil.
^S. Thompson, Motif-index of folk-literature : a classification of narrative elements in folktales, ballads, myths, fables, mediaeval romances, exempla, fabliaux, jest-books, and local legends", 1955-1958.  cf. Aarne–Thompson classification system
^Felix Ernst Peiser in "Orientalistische Literaturzeitung" (1902), as reported in Haupt.
^Theodor Nöldeke in "Zeitschrift für Assyriologie" (1914), as reported in Haupt.
(English) Paul Haupt, "Open Sesame" in Beiträge zur assyriologie und semitischen sprachwissenschaft10:2, 1927, p. 165ff. Originally presented at the meeting of the American Oriental Society, Washington, April 15, 1916.