Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

HTTP Session in AEM

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

 

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?

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @priyankak11,

 

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.

 

Avatar

Level 2
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

Avatar

Community Advisor

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

Avatar

Level 2

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

Avatar

Correct answer by
Employee Advisor

 

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?