Skip to main content
Known Participant
February 6, 2017
Answered

Saving User Variables?

  • February 6, 2017
  • 1 reply
  • 1264 views

Hello Adobe Community,

i made a javascript with language selection and some other stuff which works with user variables from captivate... now the javascript is very complex and consumes a lot of RAM, so i implemented a function that he reloads the project everytime i visit a new slide... the big problem is now that he doesnt save the user-variables, including the variable "selected_language" and he jumps everytime back to the language english after reload (or after opening the project again). i found out a solution with setting cookies with these variables, and from the local drive everything works fine, but unfortuneately our LMS systems has problems with the cookies (blocks them or something, SHA1-certifikate error) and the entire project is crashing...

Now my question: is there another way to save user variables, except of using cookies?

Best Regards

Alex

    This topic has been closed for replies.
    Correct answer michaelm71636120

    This should work with local storage. You can save the variable "selected_language" with javascript as follows:

    window.localStorage.setItem ( 'selected_language', window.cpAPIInterface.getVariableValue ( "selected_language" ) );

    Later you can retrieve the value as follows:

    window.cpAPIInterface.setVariableValue ( "selected_language", window.localStorage.getItem ( 'selected_language' ) );

    But one question: What makes your javascript consume so much RAM? This would be interesting to know, I never had problems with this so far.

    1 reply

    michaelm71636120Correct answer
    Inspiring
    February 6, 2017

    This should work with local storage. You can save the variable "selected_language" with javascript as follows:

    window.localStorage.setItem ( 'selected_language', window.cpAPIInterface.getVariableValue ( "selected_language" ) );

    Later you can retrieve the value as follows:

    window.cpAPIInterface.setVariableValue ( "selected_language", window.localStorage.getItem ( 'selected_language' ) );

    But one question: What makes your javascript consume so much RAM? This would be interesting to know, I never had problems with this so far.

    Known Participant
    February 6, 2017

    ok great, that will save the variable into the sorage like he saves the slidenumber where the user quits the project? i will try this out immdiately...

    i dont know why the RAM is getting full, maybe because he loads for example 4 implemented html's (they are on the master slide) everytime new when i visit a slide... the RAM usage is getting bigger about 30-50MB every slide, after a while everything is so laggy and jerky that it is impossible to work...

    Inspiring
    February 6, 2017

    In fact I don't know how exactly the slidenumber is saved. Local storage is (as the name suggests) only locally on your computer  (it is not saved on any LMS server or whatever). It remains on your computer even if the browser window is closed (and reopened later). You can distinguish "local storage" and "session storage" - for the difference see Web storage - Wikipedia

    So if you don't need the variable to be stored permanently (somewhere on the server), local storage should work fine in most cases.