private void HandleSubSourceCookie() { try { var cookie = Request.Cookies[SOURCE_COOKIE_NAME]; if (cookie != null) { return; } var referrer = Request.UrlReferrer != null && !String.Equals(Request.UrlReferrer.Host, Request.Url.Host, StringComparison.InvariantCultureIgnoreCase) ? (Request.UrlReferrer.Host ?? "") : ""; var source = 101; var subsource = Request.QueryString["subsource"]; if (String.IsNullOrEmpty(subsource)) { source = String.IsNullOrEmpty(referrer) ? 103 : 102; subsource = String.IsNullOrEmpty(referrer) ? Request.Url.AbsolutePath : referrer; } var sourceInfo = new SourceInfo { Src = source, Sub = subsource }; cookie = new HttpCookie(SOURCE_COOKIE_NAME, sourceInfo.Encode()); Response.Cookies.Add(cookie); } catch (Exception ex) { Global.Logger.Error("Error setting source cookie", ex); } }