There are several claims on the originality of the fortune cookie. One is that of Los Angeles and the other one is that of San Francisco.
Regarding Los Angeles, it is said that David Jung, a Chinese immigrant living in Los Angeles invented the cookie in 1918, as he wanted to offer it for free to the poor he saw wandering near his shop. Each cookie had a strip of paper with an inspirational Bible scripture on it, written for Jung by a Presbyterian minister.
Regarding San Francisco, it is said that the fortune cookie was created by a Japanese immigrant named Makoto Hagiwara, who was fired from his job by an anti-Japanese mayor, but later a new mayor reinstated him. He created the fortune cookie in 1914 including a thank you note, as he was grateful to those who had stood by him during his period of hardship.