Fix cookie setting, close #905