import and fix cookie code