So I have the following Java
for (Cookie cookie : getRequest().getCookies()) {
if (cookie.getName().equals((String) Constants.class.getDeclaredField(get('mycookie',String.class)).get(null))) {
value = cookie.getValue();
}
}
and it's returning some value to my HTL
<sly data-sly-use.courseBookmarkCookie1="${'com.myhost.core.impl.view.components.GetCookieHelper}"></sly>
<p id="doccookiejava">bookmark cookie (from java): ${courseBookmarkCookie1.value}</p>
The problem is when I do the same thing using javascript,
<script type="text/javascript">
$(document).ready(function(){
console.log(document.cookie);
});
</script>
I've encountered instances (on page refresh) where the cookie from Java is empty while document.cookie (from javascript) has a value and vice versa.
Any ideas on how to fix it? or perhaps anything I should be looking at?
I am not seeing the same issue when viewing the page on my local instance of AEM.
Thanks!
edit: I've tried my page on author and publisher (view as published) and they are working fine. seems the behavior happens when using the dispatcher.