0

Is there a way to store data for separate users in Drupal without using sessions. I have previously used Drupal varibales. But it didin't work because the variable gets updated for every user (So whenever I access the variable it shows the last users details). I can't use sessions because I have a horizontally scaled server, so when the server is changed the sessions will be deleted.

Is there a way to do this exactly as the sessions but without sessions? I need to save users data in the browser temporarily.

1
  • 1
    You can store data in the browser client side, this is no problem, but Drupal without sessions? Not possible if you want that users can log in. See this duplicate topic about load balancing with sessions drupal.stackexchange.com/questions/41373/…
    – 4uk4
    Aug 6, 2018 at 6:32

2 Answers 2

0

If you don't need your data server side, you could use cookies, using user_cookie_save. Or store your variables in window.localStorage (it's HTML5, see here for browser support) in your own javascript code/behavior, like :

function storePersistentValue() {

  //Check whether local storage is available or not

  if (window.localStorage) {

    window.localStorage.MyKey = "HTML 5 features";

  }

}

function getPersistentValue() {

  //Check whether local storage is available or not

  if (window.localStorage) {

    var text = window.localStorage.MyKey;

  }

}
0

You can use the user.data service to store user-specific data, that should persist across servers. This data is stored in the {users_data} table of the DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.