fix cookie not being used correctly