내 커뮤니티 업적 표시줄을 확대합니다.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Cookie not updating upon login successfully with another account in Sling Model AEM

Avatar

Level 2

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.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

you should add this login in HTL because pages will be cached.

Get this value using client side by setting up another non HttpOnly cookie which can be access via javascript/clienside.

Arun Patidar

AEM LinksLinkedIn

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Level 4

Hi @VuongNguyen ,

 

Just check whether your cookie is getting clear or not once you logout.

 

And make sure it should not get cached.

Avatar

정확한 답변 작성자:
Community Advisor

you should add this login in HTL because pages will be cached.

Get this value using client side by setting up another non HttpOnly cookie which can be access via javascript/clienside.

Arun Patidar

AEM LinksLinkedIn

Avatar

Community Advisor

@VuongNguyen You could probably use a unique id as a query parameter for each user on the url , which will force the url to not cache and hit the server, in case there is some caching involved.