Search code examples
apostrophe-cms

How and where to store user settings per session?


I'd like to store some user choices per session, but have no idea where and how. To keep the problem as simple as possible:

  • Lets say we have two links in the header: EN and FR (for language selecting purposes)
  • When a user clicks on one of them we should be able to store somewhere the selected option
  • Later on the site we should be able to access the selected option to take further steps to... translate some texts

So the question remains: Where and how to store the chosen language, and how to access it from anywhere on server side?


Solution

  • Not the most complete answer but you can see an illustrated example of writing and reading sessions The Apostrophe Way in the apostrophe-personas module

    https://github.com/apostrophecms/apostrophe-personas/blob/master/index.js