All locations active · 99.99% uptime
Residential Proxy

What Is a Sticky Session and How Do You Set One Up?

When you log in to a site and then appear to be coming from a different country on the second request, the platform notices immediately: same cookie, different IP. The result is usually a dropped session or a request for additional verification. Sticky sessioneliminates this problem by letting you keep the same exit IP for a defined period.

In this article we look at how a sticky session works, how to manage its duration, and how to handle drops.

The Problem: What Does an IP Change Break?

FIGUREThe consequence of an IP change mid-session
PROBLEMClientProxyPlatformLogin request (IP: A)AuthenticationSession cookieData request (IP: B)Same cookie, different IPAdditional verification / session drops

From the platform's point of view, this produces the same signal as a stolen cookie being used from another location. The defensive reflex kicks in.

How Do You Request a Sticky Session?

There are three ways to tell the gateway "send these requests through the same exit". The most common is to embed a session key in the username:

FIGUREUsername containing a session key
ANATOMYmusteri-country-tr-session-7f3a2b-ttl-15mcustomerAccount IDcountry-trExit country filtersession-7f3a2bThe key that uniquely identifies this sessionttl-15mRequested stability duration

You generate the key yourself. As long as you send the same key, the gateway tries to route you to the same node; when you change the key, you get a new exit.

MethodExampleAdvantage
In the usernameuser-session-a1Single port, unlimited sessions
Per portgateway:10001Fixed identity, practical with simple clients
Via APIPOST /session/createProgrammatic management of the session lifecycle

Key Generation: Practical Rules

FIGUREA persistent, reusable key per account
Python — session key management01import hashlib, os, time0203GATEWAY = "gateway.example.com:8000"04USER, PASS = os.environ["PROXY_USER"], os.environ["PROXY_PASS"]0506def session_key(hesap_id: str) -> str:07 # The same account should always produce the same key08 return hashlib.sha1(hesap_id.encode()).hexdigest()[:10]0910def proxy_url(hesap_id: str, ulke: str = "tr", ttl: str = "15m") -> str:11 key = session_key(hesap_id)12 user = f"{USER}-country-{ulke}-session-{key}-ttl-{ttl}"13 return f"http://{user}:{PASS}@{GATEWAY}"1415# Usage: the same account goes to the same exit on every call16proxies = {"http": proxy_url("hesap_42"), "https": proxy_url("hesap_42")}

Deriving the key from the account ID instead of generating it randomly and storing it lets you keep the same session even after the process restarts.

The most common mistake

Regenerating the key randomly on every request. In that case the session parameter is visible but useless; every request gets a new exit. Verify in your code that the key really stays constant by logging it.

TTL: How Long Should You Choose?

FIGURERecommended sticky duration by type of work
WAIT TIME1–3 min10 min30 minStatic IPProduct page scrapingIdealSuitableOverkillExcessiveCart / checkout flowInsufficientIdealSuitableSuitableAccount managementInsufficientInsufficientIdealIdealPanel sessionInsufficientInsufficientSuitableIdeal

Choosing a longer duration than necessary makes you send more requests from the same IP and increases the risk of rate limiting. Set the duration according to the real needs of the job.

For panel access that requires a persistent session and for long-running account management, using a static ISP proxy directly is more appropriate than sticky; that IP never changes.

Why Do Sticky Sessions Drop?

FIGURECauses of session drops and their solutions
DIAGNOSISCODE / SYMPTOMLIKELY CAUSESOLUTIONThe key differs on every requestRandom generation in the codeDerive the key from the account ID and log itThe TTL has expiredThe requested duration has endedExtend the duration to match the job, or renew the sessionThe node went offlineThe home device dropped off the networkRe-establish the session with the new IPA different country parameterA different country value in two requestsFix the country and the key togetherThe connection pool is getting mixed upThe same pool used with different identitiesUse a separate client/session object for each session

The first two rows stem from your own code, the third from the nature of the pool. To diagnose, first verify that the key is constant.

Handling Drops Gracefully

Sticky is not a guarantee; a node can drop off the network at any moment. The right approach is to design for a drop as an expected condition rather than treating it as an error:

01

Detect the IP change

Record the exit IP at the start of every session. If the IP has changed at a periodic check, treat the session as dropped.

02

Close the session cleanly

Keep the cookies, but do not abandon an operation midway; an unfinished operation raises suspicion on the platform.

03

Re-establish with a new key

Generate a new session key and log in again from scratch. Do not try to use the old cookie with the new IP.

04

Limit the number of retries

Many consecutive re-logins for the same account raise alarms on the platform. Put a wait between attempts.

Account–IP Mapping

If you manage multiple accounts, the most critical rule is this: every account must have its own session key and this mapping must be preserved over time. Multiple accounts appearing from the same IP is one of the strongest correlation signals platforms have.

FIGUREPersistent session mapping per account
MATCHINGPoolexit nodes1Account A → key a1always the same2Account B → key b7a different exit3The mapping is stored persistentlypreserved even if the process restarts

Keep the mapping in persistent storage (a database or a file), not in memory; otherwise your accounts get spread across different exits on every restart.

For multi-account scenarios, our social media proxy article and our product page provide additional context.

Verification: Is Sticky Really Working?

FIGUREMeasuring session stability
Terminal01# Send 6 requests with the same key and compare the exit IPs02USER="musteri-country-tr-session-test01-ttl-10m"03for i in $(seq 1 6); do04 curl -s -x "http://$USER:$PASS@gateway.example.com:8000" \\05 https://ornek-ip.example/text06 sleep 3007done0809# Expected: the same IP on all six lines10# If they differ: is the key constant, is the TTL long enough, is the node healthy?

Run this test before you buy, too. The gap between the promised duration and the actual behavior can be decisive when choosing a provider.

Summary

A sticky session is a prerequisite for any job that requires logging in. Derive the key from the account ID and store it persistently, choose the TTL according to the real needs of the job, and treat a drop as an expected condition rather than an error. If you need a permanent IP, instead of sticky static ISP proxy is the more appropriate tool. To verify your configuration, see My IP Address and proxy checker tools.

Frequently Asked Questions

01How many minutes does a sticky session last?

It varies by provider; the typical range is 1 to 30 minutes. Some services offer longer durations but give no guarantee, because the exit node can drop off the network at any moment.

02How should I generate the session key?

Generate it deterministically, not randomly: deriving it by hashing the account ID is the most practical method. That way, when the process restarts, the same account returns to the same exit.

03Can I request a different country with the same key?

No, that is a contradictory request. When the country parameter changes, the gateway looks at a different node pool and the session drops. Keep the country and the key fixed together.

04What should I do if the IP changes during a sticky session?

Treat the session as dropped and log in again from scratch with a new key. Trying to use the old cookie with a new IP is the riskiest behavior for triggering verification on the platform.

05Is sticky enough instead of a static IP?

It is enough for short- and medium-duration operations. For panel sessions that have to stay open continuously and for access that requires IP whitelisting, a static ISP proxy is needed.

Related Articles and Pages

NEXT STEP

Strengthen your proxy setup today.

Get started in minutes with a paid plan, or try our free proxy list first.

FREEPROXY.TR

Looking for a free proxy? You're in the right place

A complete proxy platform where you can browse up-to-date free proxy addresses, compare HTTP and SOCKS proxy types, and check your proxy connections with free tools.