New HttpSession on Every Request

Avatar

Avatar

Reini-

Avatar

Reini-

Reini-

29-07-2016

Hi,

I can't set any session attributes, because I get a new HttpSession on every request. To validate this, I added <%=slingRequest.getSession().getId()%> to /apps/geometrixx/components/homepage/content.jsp. Now I can see the http session id on every request to http://localhost:4502/editor.html/content/geometrixx/en.html. And I can see, this Id changes for every request so it makes no sense to set any session attributes like request.getSession().setAttribute("...", "....").

Can anybody tell me, how to get a valid http session which does not change for every single request?

Environment: Standard AEM 6.2 on Windows

 

regards

Reini

View Entire Topic

Avatar

Avatar

Abhinav_m

Avatar

Abhinav_m

Abhinav_m

29-07-2016

AEM is restful in nature and if you are relying on HTTP SESSION, then you are breaking the restful nature of AEM. You'll also not able to cache anything that is HTTP SESSION dependent.

So to use HTTP SESSION inside AEM is strongly NOT advisable.

Having said that, just to resolve your issue. You are seeing new session each time coz of following directive in your global.jsp or it might also be in your component JSP's

<%@page session="false"%>