Sometimes ActionDispatch::Cookies isn't there. middleware stack is completely impossible to conditionally insert (as far as I can tell) so just be pragmatic and insert it in approximately the right place