Access session storage in Java | Community
Skip to main content
Level 2
December 19, 2022
Solved

Access session storage in Java

  • December 19, 2022
  • 2 replies
  • 1720 views

Hi All,

I have items in session storage that I want to use in backend.

I have tried Servlet class with get method but was unable to get the item. 

Can anybody with experience help me out ?

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 arunpatidar

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/SlingHttpServletRequest.html#getCookie-java.lang.String- 

 

Here is the example

 

Cookie countryCookie = slingRequest.getCookie("myCountryCookie"); if(countryCookie==null) { String cookieValue = countryCookie.getValue(); // rest of the logic }

 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/DemoCookieFilter.java 

2 replies

arunpatidar
Community Advisor
Community Advisor
December 19, 2022

You cannot access browser session storage at server side, only cookies can be retrieve and updated from backed.

Arun Patidar
rolliedubAuthor
Level 2
December 19, 2022

.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
December 19, 2022

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/SlingHttpServletRequest.html#getCookie-java.lang.String- 

 

Here is the example

 

Cookie countryCookie = slingRequest.getCookie("myCountryCookie"); if(countryCookie==null) { String cookieValue = countryCookie.getValue(); // rest of the logic }

 

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/DemoCookieFilter.java 

Arun Patidar
Mani_kumar_
Community Advisor
Community Advisor
December 19, 2022

Once you get the cookie, map all the countries codes which you want to convert or maintain a Generic list in the AEM with all the mappings and get the values from the list

Please find the reference for using generic lists

https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists/index.html

 

Hope this is helpful