handle cookies correctly