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:
- Java
- Ruby
s.setUserId("loginId");
s.user_id = "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
:
- Java
- Ruby
s = new SessionRequest("testVisitorId", "testArrivalId", "loginId");
s = Session.create(vistor_id: "testVisitorId", arrival_id: "testArrivalId", user_id: "loginId")
If you try to call the constructor with different immutable session arguments, the call will fail with a 400 code.