Interface ISessionVariables
Provides access to the session variables.
Namespace: Softadmin.Api
Assembly: Softadmin.Api.dll
Syntax
public interface ISessionVariables
Remarks
Keep in mind that session variables are always stored and retrieved as copies. This is not an issue for immutable objects like strings but is very relevant for containers like an array. If you modify a copy of an object that you retrieved from a session variable then those changes will not affect the value in the session variable, and likewise, if you change an object after saving it as a session variable then those changes will not affect the copy that was stored.
Avoid storing large (more than a few kB) objects in the session as it negatively impacts performance.
Properties
IsSoftadminAdministrator
Gets a value indicating whether the currently logged in user is an administrator.
Declaration
bool IsSoftadminAdministrator { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No user is logged in yet. |
Item[String]
Gets or sets a session variable.
Declaration
object this[string name] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of variable, case insensitive. |
Property Value
Type | Description |
---|---|
System.Object | The |
Remarks
You can only store System.SerializableAttribute objects in the session.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | You can't overwrite the session variable with the given name. It is reserved by the platform. |
System.ArgumentException | The value is not serializable. |
System.ArgumentException | The value is too large. |
LanguageId
Gets the language ID of the currently logged in user.
Declaration
int LanguageId { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No user is logged in yet. |
RoleId
Gets the role ID of the currently logged in user.
Declaration
int RoleId { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No user is logged in yet. |
SessionId
Gets the current session ID.
Declaration
string SessionId { get; }
Property Value
Type | Description |
---|---|
System.String |
UserId
Gets the ID of the currently logged in user.
Declaration
int UserId { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No user is logged in yet. |
Username
Gets the username of the currently logged in user.
Declaration
string Username { get; }
Property Value
Type | Description |
---|---|
System.String |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | No user is logged in yet. |