Cookie not updating upon login successfully with another account in Sling Model AEM
Hi, Folks. Currently, I've facing issues that happens in my AEM project.
Overall view, my system has three type of users.
- At Login Gateway, I've setup as variables named Person Status and save it into Cookie.
- At Dashboard screen, in Sling Model Java, I'm using function as below to get Cookie and make conditions for navigation.html (sidebar.html) as below.
Here is Sling Model Java.
@Override
public String getCookieStatus() {
return CookieUtils.getCookieValue(request, Constants.PERSON_STATUS_COOKIE_NAME);
}
And then AEM HTL in Navigation Component.
<p class="nav__menu-item-subtext --small"
data-sly-test="${navItem.navItemSubtextA && navModel.cookieStatus == 'A'}">
${navItem.navItemSubtextForA}
</p>
<p class="nav__menu-item-subtext --small"
data-sly-test="${navItem.navItemSubtextB && navModel.cookieStatus == 'B'}">
${navItem.navItemSubtextForB}
</p>
<p class="nav__menu-item-subtext --small"
data-sly-test="${navItem.navItemSubtextC && navModel.cookieStatus == 'C'}">
${navItem.navItemSubtextForC}
</p>
For the first time, when I logged into Person Status = A. Navigation keeps A to render UI for A. But, I've logged out and try with another Person Status = B. The request.getCookie() return A and keep everything's for A.
The only, add url?q=1 and I can see updates executed. Was that means, Person Status = 'B" and then I saw updates with B.