Read or modify the session properties
You can change the session user and session locale. You can also run methods at the user change event.
- To change the session user, useSession.ChangeUserto authenticate another user in the session. The user name and password are passed as argumentsbool ChangeUser(string username, string password);.
- To change the session locale, create a string array by using thenew string[]syntax.IMPORTANT: Be sure to create an array. The session requires a fallback locale.This example illustrates how to set the locale to international English.Session.LocaleId = "en-US";
- To run methods at the user change event, use theUserChangeevent handler, supplied by theSessionclass.IMPORTANT: Always cancel the subscription in theStop()method to avoid a memory leak.This example illustrates how to have theSession_UserChangemethod 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 method generates a log that contains theBrowseNameof the new userTheUserChangeEventArgsdata type is a class that displays these properties:
- newUser
- Represents new user nodes.
- oldUser
- Represents old user nodes.
Provide Feedback