Fixes cookie passing in middleware