hub.eb?material_id=399&track_id=386

JavaScript API: Form Session


The Form Session represents a browser tab. You can programmatically interact with this via the client.formSession interface.

This interface contains functions that allows you to:

  • get and set attributes
  • get the session ID
  • invalidate the session

For as long as you navigate between pages and forms using server-side code, attributes in a Form Session are persisted and can be used to pass data between forms without exposing it as a URL parameter, for example.

Invalidating the session removes all form state data (field values etc.) from the Form Session. Once a Form Session has been invalidated interacting with the form results in an error. However, the Form Session itself and any attributes persist.

Steps


1

Create a form called first and attach a before page script and paste the following code:

client.formSession.setFormSessionAttribute("user_id", 209);
2

Create a second form called second and add an integer field called userId.

Drag the field onto the page.

Attach a before page script with the following code:

field.userId.value = client.formSession.getFormSessionAttribute("user_id");
3

Add a button to the first form and attach a script with the following code:

form.gotoForm("second");

 

4

Run the first form and click the button, notice that the user ID has been passed to the second form.

Current Module

Related