You can update the user s attribute in the session by admin API.
Demo
Prepaire
#1 Using Keycloak version 21.0.0

#2 Add my-realm
realm

#3 Add two users at my-realm
realm

#4 Login user
to enter session for her

Steps

#1 Get master s
access token by Postman
Detail in here
Note Make a good enough time the Access Token Lifespan
of master token. The default is 1 minute is not enough to demo

#2 Get session id by the client session statics API
GET http://localhost:8080/admin/realms/my-realm/client-session-stats

#3 Get user list in session
GET http://localhost:8080/admin/realms/my-realm/clients/[session uuid]/user-sessions

#4 Get user information with attributes
GET http://localhost:8080/admin/realms/my-realm/users/[user uuid]


#5 Update his attribute
PUT http://localhost:8080/admin/realms/my-realm/users/[user uuid]
Body of PUT
{
"id": "[user uuid]",
"username": "user name",
"attributes": {
"key1": [
"value2"
],
"key2": [
"New Value"
]
}
}

