Actions and Variables

How do I save a value in a cookie in the user's browser to be accessed in another session?

You can use a Lectora variable to store a value as a cookie in the user's browser. This value can then be accessed in a future session by this same user.

If you want to save a value as a cookie in a user's browser, the Lectora variable feature can be used.   Here are the steps to use a Lectora variable to save the value as a cookie.

  1. Create a user variable in the Variable manager.   Click on Tools, then Variables to open the Lectora Variable Manager.
    1. Click on the Add button in the lower left of the Variable Manager window.
    2. Enter a unique name in the Variable Name field
    3. Set an initial value if you want one
    4. Choose the check box next to "Retain variable value between sessions.
    5. Click the OK button midway down the page to save this variable.
    6. Click the Close button to close the Variable Manager window
  2. You can use a Lectora action to add data to this variable.  
    1. Modify Variable Set Equal To will save the data in the Action Value field to the variable.
    2. Modify Variable Add to Variable will append the data in the Action Value field to the variable
  3. When you want to access the data in the variable, you use the VAR(variableName) function, where "variableName" is replaced by the name of the variable you created in section 1 above.

This functionality will work in "Preview in a browser", and when you publish to HTML and use the Preview button to test the saving of the data in the browser cookie.