1. fix headers send, 2. auto set cookie for request if exists