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 collection of information, usually including a username and the current date and time, stored on the local computer of a person using the World Wide Web, used chiefly by websites to identify users who have previously registered or visited the site. Cookies are used to relate one computer transaction to a later one.