...how do they ever get that paper in there without it catching on fire during cooking!

The fortune isn't placed inside the cookie until after it's baked. A fortune cookie comes out of the oven flat and circular, like a regular cookie, at which point it's flipped over, the fortune is placed on top, and the whole thing is then folded up into the familiar shape (while it's still soft). Assuming they're not undercooked, they harden as they cool, leaving people like you wondering how they managed to get the fortune in there.