Fix potential bug in cookie read