Re: Session attribute in a Condition – HttpConfigurationProvider

Splash Forums Rewrite Users Session attribute in a Condition – HttpConfigurationProvider Re: Session attribute in a Condition – HttpConfigurationProvider

#23477

There is no existing condition in Rewrite that allows to check for an session attribute. But you can build one yourself very easily. If you implement your condition on top of of HttpCondition, you can get the request (and therefore also the session) from the HttpServletRewrite event. Something like this:

.defineRule()
.when(new HttpCondition() {
@Override
public boolean evaluateHttp(HttpServletRewrite event, EvaluationContext context) {
HttpServletRequest request = event.getRequest();
return request.getSession(true).getAttribute("something") != null;
}
})
.perform(.... something ...)

I hope this helps. :)