# OpcSession Members

> Reference: Represents a session which a client has created on the server.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcSession</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.server">Opc.UaFx.Server</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Properties

### Certificate

Gets the certificate of the client.

<div class="api-signature" data-lang="csharp">

```csharp
public X509Certificate2 Certificate { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Certificate As X509Certificate2
```

</div>

**Property value**

[X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2)

The [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) the client has provided when it created the session or a null reference (Nothing in Visual Basic) if it has provided none.

### ConnectTime

Gets the time at which the client has created the session.

<div class="api-signature" data-lang="csharp">

```csharp
public DateTime ConnectTime { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property ConnectTime As Date
```

</div>

**Property value**

[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)

The [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) in UTC at which the session has been created.

### Diagnostics

Gets the diagnostic information about the session.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcSessionDiagnostics Diagnostics { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Diagnostics As OpcSessionDiagnostics
```

</div>

**Property value**

[OpcSessionDiagnostics](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsessiondiagnostics/)

The [OpcSessionDiagnostics](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsessiondiagnostics/) of the session or a null reference (Nothing in Visual Basic) if there is none.

### EndpointUrl

Gets the URL of the endpoint through which the client has created the session.

<div class="api-signature" data-lang="csharp">

```csharp
public Uri EndpointUrl { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property EndpointUrl As Uri
```

</div>

**Property value**

[Uri](https://learn.microsoft.com/dotnet/api/system.uri)

The [Uri](https://learn.microsoft.com/dotnet/api/system.uri) of the endpoint or a null reference (Nothing in Visual Basic) if the URL is not an absolute URI.

### Id

Gets the identifier of the session.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeId Id { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Id As OpcNodeId
```

</div>

**Property value**

[OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/)

The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the session on the server.

### IsActive

Gets a value indicating whether the session has been activated.

<div class="api-signature" data-lang="csharp">

```csharp
public bool IsActive { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property IsActive As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the client has activated the session; otherwise the value false.

### IsExpired

Gets a value indicating whether the session has expired.

<div class="api-signature" data-lang="csharp">

```csharp
public bool IsExpired { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property IsExpired As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the time since the [LastContactTime](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/members#lastcontacttime) exceeds the timeout of the session; otherwise the value false.

### LastContactTime

Gets the time of the last contact with the client.

<div class="api-signature" data-lang="csharp">

```csharp
public DateTime LastContactTime { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property LastContactTime As Date
```

</div>

**Property value**

[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)

The [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) in UTC at which the server has received the last request of the session.

### Name

Gets the name of the session.

<div class="api-signature" data-lang="csharp">

```csharp
public string Name { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Name As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The name of the session as specified by the client.

### PreferredLocales

<span class="api-meta">since v2.11</span>

Gets a collection of preferred locales (see [Name](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.name)) to use to localize data and information.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcLocaleCollection PreferredLocales { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property PreferredLocales As OpcLocaleCollection
```

</div>

**Property value**

[OpcLocaleCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opclocalecollection/)

An instance of the [OpcLocaleCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opclocalecollection/) class with [Name](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.name)s of the cultures to use to localize data and information for this [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/).

### ServerUri

Gets the URI of the server recorded in the diagnostic information about the session.

<div class="api-signature" data-lang="csharp">

```csharp
public Uri ServerUri { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property ServerUri As Uri
```

</div>

**Property value**

[Uri](https://learn.microsoft.com/dotnet/api/system.uri)

The recorded URI as an absolute [Uri](https://learn.microsoft.com/dotnet/api/system.uri); otherwise a null reference (Nothing in Visual Basic). The server does not record a URI for its sessions, therefore the value is currently always a null reference.

### Socket

<span class="api-meta">since v2.7</span>

Gets the identity of the socket through which the client has created the session.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcSocketIdentity Socket { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Socket As OpcSocketIdentity
```

</div>

**Property value**

[OpcSocketIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsocketidentity/)

The [OpcSocketIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsocketidentity/) of the socket or a null reference (Nothing in Visual Basic) if it is not known.

### SuppliedIdentity

Gets the user identity which the client has supplied.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcUserIdentity SuppliedIdentity { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property SuppliedIdentity As OpcUserIdentity
```

</div>

**Property value**

[OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/)

The [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) supplied by the client or a null reference (Nothing in Visual Basic) if there is none.

### UsedIdentity

Gets the user identity which the server uses for the session.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcUserIdentity UsedIdentity { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property UsedIdentity As OpcUserIdentity
```

</div>

**Property value**

[OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/)

The [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) which the server has mapped the [SuppliedIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/members#suppliedidentity) to or a null reference (Nothing in Visual Basic) if there is none.

## Methods

### Close

Closes the session.

<div class="api-signature" data-lang="csharp">

```csharp
public void Close()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Close()
```

</div>

### Dispose

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [Dispose()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/members#dispose-noparams) | Releases all resources used by the [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/). |
| [Dispose(bool)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/members#dispose-system-boolean)<span class="api-meta">protected · virtual</span> | Releases the unmanaged resources used by the [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/) and optionally releases the managed resources. |

#### Dispose()

Releases all resources used by the [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/).

<div class="api-signature" data-lang="csharp">

```csharp
public void Dispose()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Dispose()
```

</div>

**Implements**

[Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)

#### Dispose(bool)

<span class="api-meta">protected · virtual</span>

Releases the unmanaged resources used by the [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/) and optionally releases the managed resources.

<div class="api-signature" data-lang="csharp">

```csharp
protected virtual void Dispose(bool disposing)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overridable Sub Dispose(disposing As Boolean)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `disposing` | [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | The value true to release both managed and unmanaged resources; otherwise the value false to release only unmanaged resources. |

### GetSubscriptions

<span class="api-meta">since v2.50</span>

Provides a sequence of [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsubscription/) instances associated with this [OpcSession](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsession/).

<div class="api-signature" data-lang="csharp">

```csharp
public IEnumerable<OpcSubscription> GetSubscriptions()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function GetSubscriptions() As IEnumerable(Of OpcSubscription)
```

</div>

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsubscription/)&gt;

An [IEnumerable&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) of [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcsubscription/) instances.
