---
title: "What Is a Sticky Session? Keeping the Same Proxy IP"
description: "A sticky session sends every connection with the same session ID through one exit IP for the time you choose. When you need it and how to pick the duration."
url: https://proxynet.io/blog/sticky-session-explained
date: 2026-12-01
author: "Acar Diveroli"
category: "Proxies"
lang: en
---

# What Is a Sticky Session? Keeping the Same Proxy IP

A sticky session is a way to keep the same exit IP on a proxy for a while. The gateway reads the session ID in the username and binds that ID to a single IP for the duration you choose. A logged-in dashboard, a filling cart or a multi-step form all depend on the server seeing you from the same address. If the address changes halfway, the session drops. This post explains how the session ID works, how to choose the duration and when a session ends early.

> **Note: Short answer**
>
> A sticky session sends connections that carry the same session ID through the same exit IP for the time you choose (1-60 minutes). It is used for work where the server remembers you, such as logins, carts and multi-step forms.

## Session ID and exit IP

In a sticky session, the gateway picks the IP, not your code. You connect to a single address, for example `pr.proxynet.io:8000`. The gateway reads the session ID in the username and binds that ID to an exit node. The exit node is the connection that carries the IP the target site sees.

The rule fits in two sentences. Every new connection with the same ID goes to the same exit. A different ID gets a different exit. How the username and password reach the gateway is covered in our [Proxy Authentication](/blog/proxy-authentication-methods) post.

The moment the exit is chosen matters. For HTTPS requests the client first opens a `CONNECT` tunnel, and the exit is set while that tunnel is built. As long as the tunnel stays open, the IP does not change. The job of a sticky session is to send later tunnels to the same exit too. Even if a connection drops, the address stays the same as long as the ID does. The product's scope is on the [Sticky Proxy](https://proxynet.io/sticky-proxy) page.

## Jobs that need a sticky session

If the server remembers you from one request to the next, you need a sticky session. That memory usually lives in a cookie. The server sends a session ID with `Set-Cookie`, and the client sends it back on later requests. Some sites also bind that cookie to the IP address. If the same cookie arrives from another IP mid-session, the site may treat it as a sign of a hijacked session.

Four typical jobs trip over this behavior:

- **Logged-in session.** In a dashboard you open with your own account, every page must come with the same cookie and from the same IP. If the IP changes, the site may ask you to log in again or for extra verification. The cookie side of the setup is in our [Sessions and Cookies in Python](/blog/python-login-session-cookies) post.
- **Cart.** Products, coupons and delivery steps are written to a cart held on the server. If the steps come from different addresses, the cart may empty or a security check may kick in.
- **Multi-step form.** Application and sign-up forms generate the key for the next step at each step. When the address changes midway, the form may start over.
- **Consistent price observation.** Price, currency and stock can vary with the visitor's location. Seeing every variant of a product from the same address lets you collect the figures under the same conditions.

What these jobs share is that each is a single flow. The IP is set when the flow starts and should not change until it ends.

## How it differs from a new IP per connection

In rotating mode, every new connection gets another exit from the pool. That is the right choice for collecting independent pages. Apply the same mode to a three-step flow and the table looks like this (the addresses come from ranges reserved for documentation):

| Step | New IP per connection | Sticky session |
|---|---|---|
| 1. Login | 203.0.113.24 | 198.51.100.7 |
| 2. Add to cart | 198.51.100.92 | 198.51.100.7 |
| 3. Checkout page | 203.0.113.181 | 198.51.100.7 |
| What the server sees | One cookie, three addresses | One cookie, one address |

In the left column the same cookie arrives from three different addresses. On a site that binds the session to the IP, the flow can break at the second step. In the right column the server sees an ordinary visitor. We covered every rotation mode in [What Is IP Rotation and How Does It Work?](/blog/ip-rotation-explained)

Watch out for one misconception. A client that keeps the connection open (keep-alive) also shows the same IP for a while, because it reuses the same tunnel. That is not a sticky session. When the tunnel closes on a timeout or a retry, the new tunnel brings a new IP. Tie continuity to the session ID, not to the connection.

## Choosing the duration: 1-60 minutes

Choose the duration for the whole job, not for a single step. The duration is the upper limit for how long the session ID stays bound to the same exit. When it runs out, the next connection goes to a new exit. At Proxynet you choose this duration between 1 and 60 minutes.

Short and long durations cost different things. A short one can cut a flow in half. A long one gathers every request on one address and raises that address's load. In residential and mobile pools the exit is a real device. The longer the duration, the higher the chance that the device leaves the network before it ends.

| Job | Starting duration |
|---|---|
| One login and a few pages | 5-10 minutes |
| Cart or checkout flow test | 10-15 minutes |
| Multi-step application form | 15-30 minutes |
| Long paginated list | As long as the list takes, 60 minutes max |
| Price round across a product group | As long as the round takes |

The values in the table are starting points. Run the flow a few times, note the longest run and add a margin. If the job exceeds 60 minutes, split it into parts and give each part a new ID.

## When a session ends early

A sticky session ends in one of two ways. The first is expected: the duration runs out and the ID moves to a new exit. The second is not: the exit device drops off the network. A home connection can shut down, or a phone can reconnect to the carrier network. Then the gateway moves the session to another exit before the time is up.

In the second case the open tunnel breaks too, because the device carrying the traffic is gone. Your client sees a connection error. When it retries, the new connection carries the same ID but exits from a different IP. If your code does not notice, the rest of the flow continues from the new address. That is exactly where the problem lies.

The right response is to restart the flow. Take a new session ID, clear the cookies and start again from the first step. For work that needs unbroken continuity, such as access registered on an IP allowlist, use a static address dedicated to you instead of a sticky session.

## Debugging

Two errors stand out in a sticky setup. Both are silent.

**A job longer than the session.** If the duration is 10 minutes and the job takes 25, the IP changes twice. You see no error in the log. Only the results drift: the second half of a price round is collected from another address, or the dashboard sends you back to the login screen. Measure how long the flow takes and compare it with the session duration.

**IDs mixing in parallel requests.** Two different symptoms share one root. If all workers share one ID, they all exit from one IP and the load piles onto that address. The reverse happens too. If a worker pool sends each request with the first free ID, the steps of a single flow spread across different IPs. Give each flow its own ID and its own cookie store. Do not hand the ID to another job until the flow ends.

The example below binds a flow to one ID and checks the exit IP before each step. The `Connection: close` header opens a new tunnel on every check. That way you see the gateway's current decision, not the address of an old tunnel.

```python
import requests

IP_ECHO = "https://api.ipify.org"
# Sticky credentials reserved for this flow
PROXY = "http://user:pass@pr.proxynet.io:8000"

class ExitIpChanged(Exception):
    pass

def exit_ip(session):
    # With Connection: close, every check opens a new tunnel
    resp = session.get(IP_ECHO, headers={"Connection": "close"}, timeout=20)
    return resp.text.strip()

def run_flow(steps, proxy_url=PROXY):
    with requests.Session() as session:  # cookie store for this flow only
        session.proxies.update({"http": proxy_url, "https": proxy_url})
        start_ip = exit_ip(session)
        for step in steps:
            if exit_ip(session) != start_ip:
                raise ExitIpChanged(f"IP changed, flow started with {start_ip}")
            step(session)
    return start_ip
```

If the IP changed, the flow stops and the calling code restarts it with a new ID. This check adds one request per step. To cut the load, run it only before critical steps such as login and checkout.

## The bottom line

Set up sticky sessions with one ID per flow, and pick the duration from the measured job time plus a margin. Above all, accept this: the duration is an upper limit, not a guarantee. For work that needs an unbroken address, use [Static Proxy](https://proxynet.io/static-proxy).

## Sources

- [RFC 6265, HTTP State Management Mechanism, section 3.1](https://www.rfc-editor.org/rfc/rfc6265#section-3.1): rfc-editor.org
- [RFC 9110, HTTP Semantics, section 9.3.6 CONNECT](https://www.rfc-editor.org/rfc/rfc9110#section-9.3.6): rfc-editor.org
- [OWASP Session Management Cheat Sheet, Binding the Session ID to Other User Properties](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#binding-the-session-id-to-other-user-properties): owasp.org

## Frequently asked questions

### How long does a sticky session last?

Between 1 and 60 minutes, as long as you choose. The duration is the upper limit for how long the session ID stays bound to the same exit. If the exit device leaves the network, the session moves to another address sooner. Pick the duration from the flow's measured time plus some margin. Split jobs longer than 60 minutes into parts and give each part a new ID.

### Is a sticky session the same as a static IP?

No. A sticky session binds an address from a shared pool to your session ID for a while. The address changes when the time runs out or the exit device drops off the network. A static IP is assigned to you and stays the same for as long as the service runs. A static address suits identities that go on an IP allowlist or must stay the same for long. A sticky session suits short flows.

### Why did the IP change before the time ran out?

Most likely the exit device left the network. In residential and mobile pools the exit is a real home connection or phone. If the device shuts down or reconnects, the gateway moves the session to another exit. Another possibility is that the client connected with a different session ID. Check that the username does not change during the flow.

### Can several jobs use the same session ID?

They can, but they all exit from the same IP. That raises the load per address, and the jobs' traces merge on one address. Give independent jobs separate IDs. The steps within one job should always use the same ID. If you use a worker pool, bind the ID to the flow, not the request, and do not hand it to another job before the flow ends.

### Is it the same as a sticky session on a load balancer?

No. The logic is the same, but the direction is reversed. On a load balancer, a sticky session routes a visitor's requests to the same backend server every time. On a proxy, your outgoing requests always leave from the same exit IP. Both keep a session going to one place. One pins incoming traffic, the other outgoing traffic.

### Does a sticky session prevent blocks?

No. A sticky session only makes the same flow leave from the same address. It does not change rate limits, robots.txt rules or a site's terms of use. If a site returns `429`, slow down and respect the `Retry-After` header. Heavy traffic from one address draws attention sooner, so keep the request rate low in a sticky session.
