Handle cookie parsing errors with middleware.