Which is the most correct code?
if (HttpContext.Current.Response.Cookies[authCookieName] != null) { HttpContext.Current.Response.Cookies[authCookieName].Value = 'New Value'; }
or
if (HttpContext.Current != null) if (HttpContext.Current.Response != null) if (HttpContext.Current.Response.Cookies != null) if (HttpContext.Current.Response.Cookies[authCookieName] != null) HttpContext.Current.Response.Cookies[authCookieName].Value = 'New Value';
If any one of HttpContext, HttpContext.Current, HttpContext.Current.Response, or Http.Current.Response.Cookies is null, you’re already in trouble. Let the exception happen and fix your web server.