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

# Sessions

> Sticky sessions and TTL on the residential network

Sessions control how long you hold the same residential IP.

* **Rotating** — every request gets a fresh IP (default)
* **Sticky** — the same IP is held for a configurable TTL

## Rotating (default)

Without a session modifier, each request pulls a new IP:

```bash theme={null}
curl -x "http://adminpcowe:maskxsndyb@pr-eu.proxies.fo:13337" https://api.ipify.org
curl -x "http://adminpcowe:maskxsndyb@pr-eu.proxies.fo:13337" https://api.ipify.org
# Each call returns a different IP.
```

Good for: scraping, SERP collection, broad crawls.

## Sticky sessions

Append `-session-<id>` to your username. Same ID = same IP.

```bash theme={null}
curl -x "http://adminpcowe-session-5s5d4xud:maskxsndyb@pr-eu.proxies.fo:13337" https://api.ipify.org
curl -x "http://adminpcowe-session-5s5d4xud:maskxsndyb@pr-eu.proxies.fo:13337" https://httpbin.org/headers
curl -x "http://adminpcowe-session-5s5d4xud:maskxsndyb@pr-eu.proxies.fo:13337" https://example.com
```

### Session TTL

Control how long the session holds the same IP with `-ttl-<minutes>`:

```
adminpcowe-session-5s5d4xud-ttl-15:maskxsndyb
```

After the TTL expires, the next request with that session ID starts a new session with a fresh IP.

Residential uses `ttl-<minutes>`. Datacenter uses `duration-<seconds>` — see [Datacenter](/datacenter/overview).

If the assigned IP drops off the network before TTL expires, a new IP is assigned and the session continues seamlessly.

### Combining with targeting

```
adminpcowe-country-us-city-westlakevillage-session-5s5d4xud-ttl-15:maskxsndyb
```

Pins a Westlake Village IP for 15 minutes.

## Picking session IDs

Alphanumeric, 6–16 characters. Same ID = same IP.

Good: `5s5d4xud`, `bot-nyc-01`, `a4f8c2e1`, `sess-7xk9m2`

Avoid:

* Spaces or special characters (`$`, `@`, `:`, `/`)
* Sequential IDs (`session-1`, `session-2`) if isolation matters
* Reusing IDs across unrelated workflows

## Code examples

<CodeGroup>
  ```python Python theme={null}
  import secrets, requests

  session_id = secrets.token_hex(4)
  username = f"adminpcowe-country-us-city-westlakevillage-session-{session_id}-ttl-15"
  proxy = f"http://{username}:maskxsndyb@pr-eu.proxies.fo:13337"

  s = requests.Session()
  s.proxies = {"http": proxy, "https": proxy}

  for _ in range(3):
      print(s.get("https://api.ipify.org").text)
  ```

  ```javascript Node.js theme={null}
  import { randomBytes } from "crypto";
  import axios from "axios";
  import { HttpsProxyAgent } from "https-proxy-agent";

  const sessionId = randomBytes(4).toString("hex");
  const agent = new HttpsProxyAgent(
    `http://adminpcowe-country-us-city-westlakevillage-session-${sessionId}-ttl-15:maskxsndyb@pr-eu.proxies.fo:13337`
  );

  const client = axios.create({ httpAgent: agent, httpsAgent: agent });

  for (let i = 0; i < 3; i++) {
    const { data } = await client.get("https://api.ipify.org");
    console.log(data);
  }
  ```
</CodeGroup>

## When to use each mode

| Scenario                                        | Mode     |
| ----------------------------------------------- | -------- |
| Scraping many pages across many sites           | Rotating |
| Logging into an account and navigating          | Sticky   |
| Adding items to a cart and checking out         | Sticky   |
| Querying an API that rate-limits per IP         | Rotating |
| Anything that checks session cookies against IP | Sticky   |

Use the shortest TTL that covers your workflow. Shorter sessions recycle IPs faster and reduce the chance of a flagged IP affecting many requests.
