fix bug of cookies not working properly