fix cookie saving bug