Skip to main content

Mutable Session Values

Mutable session arguments are set using a setter on the session object. So, if you want to keep track of when a user logs in, we can make a session argument to hold the user's ID:

session {
args {
...
userId : ID @mutable
}
...
}

In order to change the value, call the setter method on the session:

s.setUserId("loginId");

If you create a new session object with the mutable variables changed, it simply mutates those variables. So, in our example, the following is equivalent to calling setUserId:

s = new SessionRequest("testVisitorId", "testArrivalId", "loginId");

If you try to call the constructor with different immutable session arguments, the call will fail with a 400 code.