There are some cookie recipes using coffee beans. I've never tried any of them. But I am curious, if eating a cookie has the same effect as drinking coffee?
Or is all of the caffeine lost during the baking?
No, because there is no fluid in the cookie. Eating a coffee cookie will have the same effect as eating a roasted coffee bean.
Virtually no caffeine will be lost during baking, unless you bake hot enough to burn the cookies. Caffeine's melting point is 460F (237 °C). That is well above what your cookie will reach internally while in the oven.