Fix cookie logic