sessionScope (JavaScript)

Allows you to share values across pages for the duration of a session.

This global object is based on the Java class com.sun.faces.context.SessionMap which includes the following methods:
put(p0:java.lang.Object, p1:java.lang.Object) : java.lang.Object
get(p0:java.lang.Object) : java.lang.Object
For example, a button on a page might contain the following code for the onClick event:
sessionScope.put("hello", "Hello session");
A label on a second page might have the following formula:
sessionScope.get("hello");

If a user clicks the button on the first page then opens the second page, Hello session appears as the label.

The value persists as long as the session exists. If you close the application, the value is gone.

The name of the value and the value can be any object. For example, you can use the following combinations:
sessionScope.put(1, "Hello session");
sessionScope.get(1);

sessionScope.put("n", 99);
sessionScope.get("n");
You can also assign values as properties. For example, you can assign a value on the first page as follows:
sessionScope.hello = "Hello session";
On the second page, you can reference the value as follows:
sessionScope.hello;
You can bind a sessionScope variable to a control. For Data source, select EL Scopes. For Data binding, select sessionScope. You will see #{sessionScope.}. Type the name of the variable after the period, for example:
#{sessionScope.hello}