Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Last active June 30, 2016 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islaytitans/987f45d6eac07ec003a09d1cc518d49d to your computer and use it in GitHub Desktop.
Save islaytitans/987f45d6eac07ec003a09d1cc518d49d to your computer and use it in GitHub Desktop.
Sitecore personalization rule grant gated access condition
public class GrantGatedAccessCondition<T> : IntegerComparisonCondition<T> where T : RuleContext
{
protected override bool Execute(T ruleContext)
{
string cookieName = Utility.DefineCookieName();
if (HttpContext.Current.Request.Cookies[cookieName] == null)
return false;
var actualVal = HttpContext.Current.Request.Cookies[cookieName].Value;
if (String.IsNullOrEmpty(actualVal))
return false;
return true;
}
private Utility _utility;
public Utility Utility
{
get
{
if (_utility == null)
{
_utility = new Utility();
}
return _utility;
}
set { _utility = value; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment