Session variables in server side- Umbraco 12
r
I am working on COMPARE function in a product listing page. I created a UmbracoAPIController to maintain the session variables. I do a AJAXCALL to set, get and delete session variables. It is working fine in localhost. But it is not working in live website. Is my solution to use UmbracoAPIController correct? If not , please suggest an alternative solution.
r
have you tried wrapping the set up and of the session in a try catch and added logging to see if various elements are happening..
does it have have the necessary authentication etc my experience tells me that this could be a cause is the sessaion is null so you can't handle it
k
Server-side session state usually requires cookies and server affinity, or farm-level shared session state. Perhaps this would be a better job for client-side storage?
j
As above, we would need to know what your production infrastructure looked like. In a load balanced environment you may have intermittent problems, enabling affinity would forced the user to stay on the same instance which may fix your issue. If you're set on sessions, then moving the session state to SQL or something like Redis will also make this work better
r
Thanks for your response. @Ravi I will add catch logic and check if any exception is captured. I didnt set any authentication to _contextAccessor.HttpContext?.Session.SetString(sessionName, value) or fot Getstring(). Also I don't know what authentication to set. @kdx-perbol Yes. Client-side storage works too. Thanks for the suggestion. @Jamie T Ours is not a load balanved environment. If either of the above two solutions doesn't solve my problems, I will get back to you.
157 Views