Store information in session



I have an implementation in AEM where I need to store data in session, I tried to use cookies but it exceed 4KB cookie size. I would like to avoid using HTTPSession is not a best practice in AEM.

I have an option to set values using local storage in browser or contexthub using JS. Do we have a way to set and get values directly using Java API and Servlets?