CQ dispatcher - Cookie issue | Community
Skip to main content
prohira
Level 3
October 16, 2015
Solved

CQ dispatcher - Cookie issue

  • October 16, 2015
  • 3 replies
  • 4019 views

I have a component where I am creating cookie by using below code:

Cookie cookie = new Cookie("testCookie", "cookieValue");

slingResponse.addCookie(cookie);

My cookie is getting created in browser but at the same time page is getting cached in dispatcher. The problem comes when another user comes to visit the page. Of course he will get the cached page from dispatcher and above cookie won't get created for him.

I have an omniture tracking code written in JS which is dependent on cookie existence.

How do I resolve this issue?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Scott_Brodersen

Read about Client Context and see if it meets your requirements: http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html

scott

3 replies

Scott_Brodersen
Scott_BrodersenAccepted solution
Level 8
October 16, 2015

Read about Client Context and see if it meets your requirements: http://docs.adobe.com/docs/en/aem/6-0/develop/personalization/client-context.html

scott

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

The creation of the cookie is dynamic by nature, and therefor the page must not be cached. You have 2 options:

  • Do not cache these pages, which create cookies, or
  • You create the cookie in a more lightweight call (e.g on an AJAX call), which then creates the cookie.

When you design and develop your pages, you must have caching in mind, and the limitations it brings.

Kind regards,
Jörg

Community Advisor
October 16, 2015

You could try permission sensitive caching, more details can be found at

http://helpx.adobe.com/experience-manager/kb/PSCachingDelivery.html