Skip to content
Glossary

What is a sticky session?

Definition

A proxy setting that holds one exit address for a period, or, on a load balancer, a cookie that pins each visitor to one backend server.

Read the full guideSticky vs rotating proxies: when to change the IPSticky vs rotating proxies: which suits each task, why a pooled client never rotates, and the session-ID pattern that failed at request…

The term has two meanings, and both apply when you collect data through a proxy. On the proxy side, a sticky session holds the same exit address for a period, so a multi-step flow reaches the site from one address. On the site side, load balancers use the same words for session affinity: pinning each visitor to one backend server, so state kept in that server’s memory survives between requests. The first is yours to ask for. The second belongs to the site, and you usually notice it only when it breaks.

Proxy sticky session Load-balancer sticky session
Who sets it You, through the proxy credentials or port The site’s operator
What stays fixed The exit address the site sees The backend server that answers you
What carries it A session label in the proxy username, or a dedicated port A cookie the load balancer issues
What ends it The provider’s timer, or the exit device leaving the network The cookie expiring, or the backend becoming unhealthy
What failure looks like Your address changes in the middle of a flow You land on a server that has never seen your session

The proxy kind: a label in the username

Where a provider offers stickiness through credentials, the label goes in the username, and the exact syntax differs between providers. Treat user-session-a1b2 below as a placeholder for whatever format yours documents. The mechanism underneath does not vary. We pointed curl 8.7.1 at a logging proxy on 127.0.0.1 on 21 October 2026 and fetched two URLs in one command:

curl -x http://user-session-a1b2:pass@127.0.0.1:8899 https://example.com/ https://example.com/

The proxy received one tunnel request, with the label inside the credentials:

CONNECT example.com:443 HTTP/1.1
Host: example.com:443
Proxy-Authorization: Basic dXNlci1zZXNzaW9uLWExYjI6cGFzcw==
User-Agent: curl/8.7.1
Proxy-Connection: Keep-Alive
$ echo dXNlci1zZXNzaW9uLWExYjI6cGFzcw== | base64 -d
user-session-a1b2:pass

The label is just part of the username, Base64-encoded under the Basic scheme like the rest of the credentials, and it arrives with every new tunnel. A second command with user-session-c3d4 produced a different header value, which is all a gateway needs to treat it as a different session. So changing one character of the label is how you ask for a fresh address on demand, and keeping it identical is how you ask for the same one.

Asking is not the same as getting. A residential exit is someone’s device, and when it goes offline the gateway has to put your label on a different exit, sticky or not. Check the exit address before any step that depends on it rather than assuming it held. The section “Stickiness is best-effort” in Rotating vs sticky sessions covers how to detect a session that ended early, and the curl guide shows how to run a sticky session from the command line.

AWS documents the behaviour of its Application Load Balancer in detail, so it serves as the example here. With duration-based stickiness, the load balancer picks a target for your first request and sets a cookie named AWSALB that encodes and encrypts the choice. It also sets AWSALBCORS, carrying the same information with SameSite=None; Secure for cross-origin requests. The stickiness duration can be set “between 1 second and 7 days”, and the load balancer resets the cookie’s expiry after every request. If the cookie refers to a target that was deregistered or is unhealthy, the load balancer picks a new one and rewrites the cookie.

For a scraper the lesson is to keep the cookie jar. A client that drops cookies between requests is routed afresh each time, and a login or a basket held in one server’s memory vanishes. That failure can look like a block. It is not one, and changing proxies will not fix it.

Keeping both kinds in step

Keep both kinds of stickiness together for the length of a flow. One session label plus one cookie jar means the site sees one address and one session, and its load balancer keeps you on one server. Change the label but keep the cookies, and the site sees a known session arriving from a new address, which it may treat as suspicious.

Python clients hold cookies and connections in a session object. The section “Keeping a session on one address” in Using proxies in Python pairs one with a session-labelled proxy URL, so the cookies and the address stay together.

Frequently asked questions

How long does a proxy sticky session last?
As long as the provider's cap allows and the exit device stays online, whichever ends first. Treat the advertised duration as a maximum, and re-check the exit address before any step that depends on it.
How do I get a new IP during a sticky session?
Change the session label in the username, or wait for the timer to run out. Sending the same label asks for the same exit.
What is a sticky session on a load balancer?
Session affinity: the load balancer pins a client to one backend server, usually with a cookie. On an AWS Application Load Balancer the duration-based cookie is called AWSALB, and the stickiness duration can be set from 1 second to 7 days.

Sources

  1. AWS: Sticky sessions for your Application Load Balancer
  2. RFC 6265: HTTP State Management Mechanism
  3. RFC 7617: The Basic HTTP Authentication Scheme
  4. RFC 9110 section 11.7.2: Proxy-Authorization

All terms, A to Z