HTTP Session in AEM | Community
Skip to main content
Level 2
Jun 2, 2021 9:54 AM UTC
Solved

HTTP Session in AEM

We have requirement to store a long string (end-user specific) in a cookie but because of the size limitation of the cookie, we are not able to store it.  We are required to send this String with every call to the database.  We are using MarkLogic database here. Please suggest what will be drawback of using HTTP Session to store that?

Also,  is there any other way to store it? We have multiple AEM instances in production.

Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Jun 3, 2021 2:59 PM UTC

 

I would question the application design when you constantly need to send more than 4k from the client to the server. Does this payload change with every request?

If not, the first natural approach is a server-side session, but this design does not scale at all, and is often problematic in terms of failover, its more and more discouraged. AEM does not encourage to use server-side sessions, because that as a really bad impact on your application performance, when you need to render a lot requests and cannot cache them. Naturally your publish instances will become a bottleneck.

 

Why don't you store that data once in the database and the browser just sends an ID in a cookie, so the application can reference it?

5 replies

joerghoh
joerghohAccepted solution
Employee
Jun 3, 2021 2:59 PM UTC

 

I would question the application design when you constantly need to send more than 4k from the client to the server. Does this payload change with every request?

If not, the first natural approach is a server-side session, but this design does not scale at all, and is often problematic in terms of failover, its more and more discouraged. AEM does not encourage to use server-side sessions, because that as a really bad impact on your application performance, when you need to render a lot requests and cannot cache them. Naturally your publish instances will become a bottleneck.

 

Why don't you store that data once in the database and the browser just sends an ID in a cookie, so the application can reference it?

Translate
Level 2
Jun 2, 2021 2:48 PM UTC

I am not Using session because session will slow down the performace and using HTTP Session is not recommended by Adobe.

Translate
Umesh_Thakur
New Participant
Jun 2, 2021 2:46 PM UTC

If cookie has some limitation in your case then why did you not go with the sessionStorage and localStorage for the same purpose if you go with javascript way. In java you can easily take help from HTTP session api itself for the same.

 

Hope this will help.

Umesh Thakur

Translate
Kiran_Vedantam
New Participant
Jun 2, 2021 2:18 PM UTC

Hi @priyanka1105,

 

What is the size of the cookie? Which places did you try saving them? Did you try both java and java-script?

 

Thanks,

Kiran Vedantam.

 

Translate
Level 2
Jun 2, 2021 2:50 PM UTC
cookie size is more than 4096 bytes. When I am trying to store more than that, Cookie is not able to take it.e it
Translate