Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitecore Personalization rule for levelled gated access
public class GrantGatedAccessLevelledCondition<T> : IntegerComparisonCondition<T> where T : RuleContext
{
public int No { get; set; }
...
protected override bool Execute(T ruleContext)
{
string cookieName = Utility.DefineCookieName();
if (HttpContext.Current.Request.Cookies[cookieName] == null)
return false;
var actualLevel = HttpContext.Current.Request.Cookies[cookieName].Value;
if (string.IsNullOrEmpty(actualLevel))
return false;
int actualLevelInt;
if (!int.TryParse(actualLevel, out actualLevelInt))
return false;
Value = No;
return Compare(actualLevelInt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.