merge in sm217s cookie code (which is work in progress)