use middleware for warper cookie
(cherry picked from commit 13347440b5a007f938fcabde487d6e72362ae6df)