> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nodemaven.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage sessions with the SDKs

> Create sticky sessions, set a lifetime, and generate session IDs for workers.

Reuse a sticky session, request a lifetime, and generate session IDs for workers.

A sticky session asks the gateway to keep an exit IP for related requests. Use it when a workflow needs a consistent visitor identity across pagination, form submissions, or an authenticated session.

The session lives at the gateway. The SDK builds its parameters; it does not store browser cookies, keep connections alive, or reserve a dedicated IP.

The examples below assume the credentials and dependencies from your [Python](https://docs.nodemaven.com/developer-sdks/python.md), [Rust](https://docs.nodemaven.com/developer-sdks/rust.md), or [Go](https://docs.nodemaven.com/developer-sdks/go.md) quickstart. Rust and Go snippets belong inside a function that handles results or errors.

## Create a sticky session

Build a configuration and attach a session ID. Reuse the resulting object for related requests.

**Python**

```python theme={null}
from nodemaven import Proxy

base = Proxy(country="us", filter="medium")
held = base.session("order4417")
```

**Rust**

```rust theme={null}
let base = nodemaven::Proxy::builder()
    .param("country", "us")
    .param("filter", "medium")
    .build()?;
let held = base.session("order4417")?;
```

**Go**

```go theme={null}
base, err := nodemaven.New(
    nodemaven.WithParam("country", "us"),
    nodemaven.WithParam("filter", "medium"),
)
if err != nil {
    return err
}
held, err := base.Session("order4417")
if err != nil {
    return err
}
```

Pass `held` to your HTTP client using the same helper as in the quickstart. If you create a new session object, update the client's proxy configuration too. An existing client will not automatically switch to a new SDK object.

## Request a session lifetime

Add a `ttl` parameter before creating the session. These alternatives replace the earlier initialization and request ten minutes:

**Python**

```python theme={null}
held = Proxy(country="us", filter="medium", ttl="10m").session("order4417")
```

**Rust**

```rust theme={null}
let held = nodemaven::Proxy::builder()
    .param("country", "us")
    .param("filter", "medium")
    .param("ttl", "10m")
    .build()?
    .session("order4417")?;
```

**Go**

```go theme={null}
base, err := nodemaven.New(
    nodemaven.WithParam("country", "us"),
    nodemaven.WithParam("filter", "medium"),
    nodemaven.WithParam("ttl", "10m"),
)
if err != nil {
    return err
}
held, err := base.Session("order4417")
if err != nil {
    return err
}
```

Use lowercase units. The SDK repositories document `1m`, `10m`, `10h`, and `24h` as accepted examples. The product's sticky-session limit is up to 24 hours, subject to the exit remaining available. Setting a lifetime does not guarantee that the original IP will remain online for that period.

See [How sticky sessions work](https://docs.nodemaven.com/residential-mobile/sticky-sessions.md) for product behavior and duration settings.

## Keep the parameters consistent

A session identity depends on more than its ID. In particular, changing the location, proxy pool, or filter can select a different identity even if you reuse the same `sid`.

Build the configuration once for a workflow and reuse it. To change it deliberately, create a new object:

**Python**

```python theme={null}
germany = held.replace(country="de")
fresh = held.session("order4418")
```

**Rust**

```rust theme={null}
let germany = held.with_param("country", "de")?;
let fresh = held.session("order4418")?;
```

**Go**

```go theme={null}
germany, err := held.With("country", "de")
if err != nil {
    return err
}
fresh, err := held.Session("order4418")
if err != nil {
    return err
}
```

These calls return new objects. They do not modify `held`, update a running browser, or transfer application cookies to another session.

## Generate session IDs for workers

Use `sessions` to generate configurations with separate random session IDs:

**Python**

```python theme={null}
workers = base.sessions(5)
for worker in workers:
    print(worker.username)
```

**Rust**

```rust theme={null}
let workers = base.sessions(5)?;
for worker in workers {
    println!("{}", worker.username());
}
```

**Go**

```go theme={null}
workers, err := base.Sessions(5)
if err != nil {
    return err
}
for _, worker := range workers {
    fmt.Println(worker.Username())
}
```

Assign one configuration to each worker and keep it for that worker's workflow. The helper generates session IDs; it does not start workers or create simultaneous connections. Distinct IDs should not be treated as a guarantee of five unique or dedicated public IPs.

Session IDs cannot contain `-` or whitespace. For example, use `worker01`, not `worker-01`. The generated IDs avoid these characters.

## Use a configuration without a sticky session

Remove `sid` and any sticky-session lifetime when you no longer want to request a pinned identity:

**Python**

```python theme={null}
rotating = held.replace(sid=None, ttl=None)
```

**Rust**

```rust theme={null}
let rotating = held.without_param("sid")?.without_param("ttl")?;
```

**Go**

```go theme={null}
rotating, err := held.Without("sid")
if err != nil {
    return err
}
rotating, err = rotating.Without("ttl")
if err != nil {
    return err
}
```

A configuration without `sid` does not request a sticky session. When testing rotation, consider your client's persistent connections: two application requests can reuse an existing tunnel. Verify the exit with actual requests rather than assuming that each SDK object or client request creates a new connection.

## Understand when an IP can change

| Situation | What to expect |
| - | - |
| Same session ID and stable targeting/filter settings | The gateway attempts to reuse the sticky exit while it is available and within the session lifetime |
| Session expires or the original exit goes offline | Sticky behavior can move the session to another IP |
| You change the session ID, location, pool, or filter | Treat this as a different proxy identity |
| You need the dashboard's No rotating behavior | The SDK builder does not accept `norotate` in the documented versions |

Sticky sessions are different from the [No rotating](https://docs.nodemaven.com/residential-mobile/session-types.md) mode and from [ISP proxies](https://docs.nodemaven.com/isp/overview.md), which are a separate product.

## Next steps

* [Review proxy configuration options](https://docs.nodemaven.com/developer-sdks/configuration.md)
* [Check the connection and troubleshoot changing exits](https://docs.nodemaven.com/developer-sdks/connection-checks.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.