1703, American English, from Dutch koekje "little cake," diminutive of koek "cake," from Middle Dutch koke (see cake (n.)). Slang application to persons attested since 1920. Phrase that’s the way the cookie crumbles "that’s the way things happen" is from 1957.

A website called “About English Idioms” says that starting in 1920, the term cookie was used to refer to a person or to “an alluring young woman.” The phrase smart cookie was first used in 1948 and it can refer to both men and women, as can the term tough cookie.

The writer of the article goes on to say that she’s never heard of anyone using the terms smart cookie or tough cookie in everyday speech. She’s obviously never met Eric!