+ Start a Discussion
Kumar_ShahKumar_Shah 

Session scope variable

Hello,

I want to store a value which can be accessed throughout the entire user's session in the community. When user logout or session times out, it should reset the value. Similar to session variable in .NET/C#. I tried with the following options:

1. Static - Scope is limited to the per transaction and resets. 
2. Global - I tried to store in global variable however, the stored value is not accessible when I refresh the page in Community. 
3. Custom Setting - It has the option to store as Hierarchy but my application has more than 10k users and I can't store the value upfront for each user
4. Platform cache - It works but the behaviour is not consistent. Sometimes, it returns the correct value and some time, it is null.

I don't want to store a value as a custom field on a user object. Is there a better solution.

Thanks,