Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Not able to read cookie value from request object in AEM as Cloud without query param

Avatar

Level 1

Hi,
I have this logic to read the cookies

Optional<Cookie[]> cookies = Optional.ofNullable(request.getCookies());

if (cookies.isPresent()) {
return Arrays.stream(cookies.get()).filter(cookie -> cookie.getName().equals(cookieName))
.map(cookie -> cookie.getValue()).findFirst();
}

return Optional.empty();


Now the problem is If i hit my page URL from akamai or AEM Publish URL without query param then i am not able read cookie value but if i hit same URL with query param then i am getting correct response. Let my cookie name is ABC and its present in both the cases : with query param and without query param. Also this issue is only happening in one environment and not in other. Is there any configuration which blocks request object to get the cookies?? Because i faced a similar issue where i am not able to read the i18n values until and unless i dont pass query param in URL. Here the main issue is about reading the cookies which i am not able to read if i dont pass some query param even though the cookie is present

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi @JavedKh ,

I think your issue is caused by Akamai caching behavior and how it forwards requests to AEM Publish. When you hit the URL without a query parameter, Akamai may serve a cached response and not forward the original request (including cookies) to AEM. When you add a query parameter, Akamai treats it as a unique request, bypasses the cache, and forwards the full request including cookies to AEM.

This behavior is environment-specific because Akamai configurations (like cache key rules and cookie forwarding) can differ between environments.

Try these - 

 

  1. Akamai Config: In Property Manager, enable cookie forwarding to origin.
    Ensure cache key doesn’t rely on query param to forward cookies.
  2. Dispatcher Config:- Add "Cookie" in /clientheaders of dispatcher.any.
  3. Optional:-  Add Cache-Control: no-cache headers in response to bypass Akamai cache.

 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @JavedKh ,

Can you try to follow below steps and see if it helps:-

  1. Inspect HTTP Headers:

    • Use browser developer tools or a tool like Postman to inspect the HTTP headers in both scenarios (with and without query parameters). Check if the cookie is being sent in the request headers in both cases.
  2. Environment Configuration:

    • Compare the configuration settings between the two environments. Look for differences in server settings, proxy configurations, or any middleware that might affect cookie handling.
    • Security Settings:

      • Check if there are any security settings (e.g., SameSite, Secure, HttpOnly) that might be affecting cookie transmission.

 

Like if  cookie is marked as Secure Flag it will only be transmitted over HTTPS connections. If your AEM instance or the request is not using HTTPS, the browser will not send the cookie, and it will not be available in the request object.

 

 

-Tarun

Avatar

Correct answer by
Level 5

Hi @JavedKh ,

I think your issue is caused by Akamai caching behavior and how it forwards requests to AEM Publish. When you hit the URL without a query parameter, Akamai may serve a cached response and not forward the original request (including cookies) to AEM. When you add a query parameter, Akamai treats it as a unique request, bypasses the cache, and forwards the full request including cookies to AEM.

This behavior is environment-specific because Akamai configurations (like cache key rules and cookie forwarding) can differ between environments.

Try these - 

 

  1. Akamai Config: In Property Manager, enable cookie forwarding to origin.
    Ensure cache key doesn’t rely on query param to forward cookies.
  2. Dispatcher Config:- Add "Cookie" in /clientheaders of dispatcher.any.
  3. Optional:-  Add Cache-Control: no-cache headers in response to bypass Akamai cache.

 

Avatar

Community Advisor

Hi @JavedKh,

  • Check if Cookie header is being sent in both cases (with/without query param). - Use browser DevTools > Network tab > Request Headers

  • Use Akamai Debug Headers (eg. Pragma: akamai-x-cache-on) to inspect if response is cached or coming from origin.

Dispatcher could be configured to ignore or block Cookie headers based on:

  • Cache rules (/cache block)

  • /headers block (which headers are passed to AEM)

  • /clientheaders not including Cookie

Check dispatcher.any:

/clientheaders {
    ...
    "Cookie"
    ...
}

If Cookie is not listed here, it will not be forwarded to AEM.

 

You can troubleshoot and Compare curl or Postman requests: With and without query param

curl -I -H "Cookie: ABC=value" "https://your-domain.com/page"
curl -I -H "Cookie: ABC=value" "https://your-domain.com/page?test=true" 

Santosh Sai

AEM BlogsLinkedIn