Fix bugs related to cookie