import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'


The Glasswall library is session based. Sessions act as a means to store data against a session ID.
The **GW2OpenSession** function creates a new session.

<Tabs>

<TabItem value="C++" label="C++" default>

**Synopsis**

Create a new session and returns the session ID

```cpp
#include "glasswall.core2.api.h"
Session GW2OpenSession(void);
```

**Returns**

If successful, the  **GW2OpenSession**  function returns a handle, a small positive integer that designates the session.
The handle is used as an argument to other API functions to identify the session.
If the call fails, the handle will be zero.

**Example**

```cpp

#include "glasswall.core2.api.h"

Session session = GW2OpenSession();

if (!session)
    /* deal with error */
else
    /* use session to refer to the session in other API function calls */

if (GW2CloseSession(session))
    /* error closing session */

```

</TabItem>

<TabItem value="C#" label="C#">

**Synopsis**

Creates a new Glasswall session

```csharp
/// <summary>
/// Creates a new Glasswall session
/// </summary>
/// <returns>A handle, a small positive integer that designates the session</returns>
public int OpenSession()

```

**Returns**

A handle, a small positive integer that designates the session

</TabItem>

<TabItem value="Java" label="Java">

**Synopsis**

```java
import com.glasswall.core2javabridge.*;

public int GW2OpenSession() throws GlasswallException
```

**Returns**

The **GW2OpenSession** function returns a unique positive `int` that designates the session.

A **GlasswallException** exception will be thrown if a new session cannot be created.

</TabItem>

<TabItem value="Python" label="Python">

**Synopsis**

Opens a new Glasswall session.

```py
def open_session(self):
    """ Open a new Glasswall session.

    Returns:
        session (int): An incrementing integer representing the current session.
    """
```

**Returns**

An incrementing integer representing the current session

</TabItem>

<TabItem value="JavaScript" label="JavaScript">

**Synopsis**

This function requests the creation of a new glasswall session.

```jsx
**
 * This function requests the creation of a new glasswall session.
 * @returns {number} The handle to the new session, as a small positive integer. Failure returns 0.
 */

GW2OpenSession()
```

**Returns**

The handle to the new session, as a small positive integer.

</TabItem>

</Tabs>