Sling Filters with cookies | Community
Skip to main content
anelem1760873
Level 4
Feb 26, 2019 10:11 AM UTC
Solved

Sling Filters with cookies

Hi Guys,

I am trying to open an asset or a page in AEM based on if the the cookie is available for that specific Asset or Page. if the cookie is available access must granted else redirect to a form. The cookie will be created on submission of the form. Can you guys give me a direction on how should I go about doing this.

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
Feb 26, 2019 3:15 PM UTC

I'm not sure that you're creating the cookie or client side (js/jquery) or server side (java).

Based on that design approach, you could simply redirect the request in either js using window.location(path) or response.sendRedirect(path), response.setStatus(301) and response.setHeader("Location",path)

you should check for the cookie existence and do the redirect in client side to avoid access to content in case it is cached in dispatcher.

you may have to do the same in both places based on the flow of request and number of entry points for your use case.

HTH

1 reply

Gaurav-Behl
Gaurav-BehlAccepted solution
Level 10
Feb 26, 2019 3:15 PM UTC

I'm not sure that you're creating the cookie or client side (js/jquery) or server side (java).

Based on that design approach, you could simply redirect the request in either js using window.location(path) or response.sendRedirect(path), response.setStatus(301) and response.setHeader("Location",path)

you should check for the cookie existence and do the redirect in client side to avoid access to content in case it is cached in dispatcher.

you may have to do the same in both places based on the flow of request and number of entry points for your use case.

HTH

Translate