Read or modify the session propertiesΒΆ

Change the session user

Refer to the API Session.ChangeUser(username, password) ChangeUser.

Change the session locale

To change the session locale, create a string array using the new string[] syntax.

Note

it is necessary to create an array because the session requires a fallback locale (see Fallback locale).

Below is an example of setting the locale to international English and Italian.

Session.LocaleIds = new string[] {"en-US", "it-IT"};

Run methods on change of user

To execute methods at the user change event use the UserChange event handler, supplied by the `` Session`` class.

Warning

Always cancel the subscription in the Stop() method to avoid a memory leak.

Below is an example in which the Session_UserChange method is executed at each user change, until cancellation of the subscription:

public override void Start()
{
    Session.UserChange += Session_UserChange;
}

private void Session_UserChange(object sender, UserChangeEventArgs e)
{
    Log.Info(e.newUser.BrowseName);
}

public override void Stop()
{
    Session.UserChange -= Session_UserChange;
}

The UserChangeEventArgs data type is a class that displays the two properties newUser and oldUser, which represent the nodes of the new and the old user respectively. In the previous example, the Session_UserChange method generates a log that contains the BrowseName of the new user.