/// <summary>
    /// Changes the cookie level
    /// </summary>
    /// <param name="newLevel">New cookie level to set</param>
    private void ChangeLevel(int newLevel)
    {
        if (PortalContext.ViewMode.IsLiveSite())
        {
            // Keep the current contact as this value will be lost once the cookie level gets lower than the "Visitor" level
            var originalContact     = ContactManagementContext.CurrentContact;
            var originalCookieLevel = cookieLevelProvider.GetCurrentCookieLevel();

            cookieLevelProvider.SetCurrentCookieLevel(newLevel);

            if (!String.IsNullOrEmpty(TrackingConsent))
            {
                if ((newLevel >= CookieLevel.Visitor) && (originalCookieLevel < CookieLevel.Visitor))
                {
                    AgreeConsent();
                }
                else if ((originalCookieLevel >= CookieLevel.Visitor) && (newLevel < CookieLevel.Visitor))
                {
                    RevokeConsent(originalContact);
                }
            }

            if (!UseUpdatePanel)
            {
                // Make a full client-side reload after the cookie level is changed.
                // Campaigns feature needs to have the visitor cookie level set at the beginning of a request in order to log campaign statistics.
                URLHelper.Redirect(RequestContext.RawURL);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Changes the cookie level
    /// </summary>
    /// <param name="newLevel">New cookie level to set</param>
    private void ChangeLevel(int newLevel)
    {
        if (PortalContext.ViewMode.IsLiveSite())
        {
            // Keep the current contact as this value will be lost once the cookie level gets lower than the "Visitor" level
            var originalContact     = ContactManagementContext.CurrentContact;
            var originalCookieLevel = cookieLevelProvider.GetCurrentCookieLevel();

            cookieLevelProvider.SetCurrentCookieLevel(newLevel);

            if (!String.IsNullOrEmpty(TrackingConsent))
            {
                if ((newLevel >= CookieLevel.Visitor) && (originalCookieLevel < CookieLevel.Visitor))
                {
                    AgreeConsent();
                }
                else if ((originalCookieLevel >= CookieLevel.Visitor) && (newLevel < CookieLevel.Visitor))
                {
                    RevokeConsent(originalContact);
                }
            }
        }
    }