Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

HTTP Session in AEM

priyankak11
Level 2
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
Jörg_Hoh
Correct answer by
Employee
Employee

 

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

0 Replies
KiranVedantam1992
Community Advisor
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.

 

priyankak11
Level 2
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
Umesh_Thakur
Community Advisor
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

priyankak11
Level 2
Level 2

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

Jörg_Hoh
Correct answer by
Employee
Employee

 

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