Skip to main content

Session Management

WeProxies supports both rotating IPs (new IP per request) and sticky sessions (same IP across multiple requests). Understanding when to use each is key to successful proxy usage.

Rotating Sessions (Default)

By default, every request receives a different IP address from our pool:

# Each request gets a new IP
curl -x "http://wp_user:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 192.168.1.1

curl -x "http://wp_user:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 203.45.67.89

curl -x "http://wp_user:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 156.78.90.12

When to Use Rotating IPs

  • ✅ Web scraping at scale
  • ✅ Data collection from multiple pages
  • ✅ Avoiding rate limits per IP
  • ✅ Anonymous browsing
  • ✅ Search engine scraping

Sticky Sessions

Sticky sessions maintain the same IP address for a period of time by adding a session parameter:

USERNAME-session-YOUR_SESSION_ID

Basic Example

# Same session ID = same IP
curl -x "http://wp_user-session-mysession123:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 192.168.1.100

curl -x "http://wp_user-session-mysession123:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 192.168.1.100 (same IP!)

curl -x "http://wp_user-session-mysession123:password@proxy.weproxies.com:1080" https://api.ipify.org
# → 192.168.1.100 (still the same!)

Session Duration

Sticky sessions last for up to 10 minutes of inactivity. The timer resets with each request:

ActivitySession Status
Request at 0:00Session started
Request at 5:00Session active, timer reset
Request at 12:00Session active, timer reset
No requests for 10 minSession expires, new IP assigned

When to Use Sticky Sessions

  • ✅ Login and authentication flows
  • ✅ Multi-step checkout processes
  • ✅ Form submissions
  • ✅ Session-based websites
  • ✅ Social media account operations
  • ✅ Any workflow requiring consistent identity

Session ID Best Practices

Use Unique, Meaningful IDs

import uuid

# Good: Unique per task/account
session_id = f"user-{user_id}-{uuid.uuid4().hex[:8]}"
proxy = f"http://wp_user-session-{session_id}:password@proxy.weproxies.com:1080"

# Good: Task-specific
session_id = f"checkout-order-{order_id}"
proxy = f"http://wp_user-session-{session_id}:password@proxy.weproxies.com:1080"

Avoid Reusing Sessions Across Unrelated Tasks

# Bad: Same session for different accounts
proxy = "http://wp_user-session-shared:password@proxy.weproxies.com:1080"

# Good: Unique session per account
for account in accounts:
proxy = f"http://wp_user-session-{account.id}:password@proxy.weproxies.com:1080"

Code Examples

Python - Login Flow with Sticky Session

import requests
import uuid

class SessionProxy:
def __init__(self, username, password):
self.username = username
self.password = password
self.session_id = uuid.uuid4().hex[:16]
self.http_session = requests.Session()

@property
def proxies(self):
return {
"http": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080",
"https": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080"
}

def login(self, site_url, credentials):
# All requests use the same IP
response = self.http_session.post(
f"{site_url}/login",
data=credentials,
proxies=self.proxies
)
return response

def get_dashboard(self, site_url):
# Still using the same IP
response = self.http_session.get(
f"{site_url}/dashboard",
proxies=self.proxies
)
return response

# Usage
proxy = SessionProxy("wp_user", "password")
proxy.login("https://example.com", {"user": "test", "pass": "123"})
dashboard = proxy.get_dashboard("https://example.com")

Node.js - Persistent Session

const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent');
const { v4: uuidv4 } = require('uuid');

class ProxySession {
constructor(username, password) {
this.username = username;
this.password = password;
this.sessionId = uuidv4().replace(/-/g, '').slice(0, 16);
}

get agent() {
const proxyUrl = `http://${this.username}-session-${this.sessionId}:${this.password}@proxy.weproxies.com:1080`;
return new HttpsProxyAgent(proxyUrl);
}

async request(url, options = {}) {
return axios({
url,
...options,
httpsAgent: this.agent,
timeout: 30000
});
}
}

// Usage
const session = new ProxySession('wp_user', 'password');

async function loginFlow() {
// Login request
await session.request('https://example.com/login', {
method: 'POST',
data: { username: 'test', password: '123' }
});

// Subsequent requests use same IP
const dashboard = await session.request('https://example.com/dashboard');
console.log(dashboard.data);
}

loginFlow();

Python - Sticky Session with Country

import requests

def create_session_proxy(username, password, country=None, session_id=None):
"""Create proxy URL with optional country and session."""
user = username

if country:
user += f"-country-{country}"

if session_id:
user += f"-session-{session_id}"

return {
"http": f"http://{user}:{password}@proxy.weproxies.com:1080",
"https": f"http://{user}:{password}@proxy.weproxies.com:1080"
}

# Sticky session from US
proxy = create_session_proxy(
"wp_user",
"password",
country="US",
session_id="us-session-001"
)

# All requests use same US IP
session = requests.Session()
session.proxies.update(proxy)

response1 = session.get("https://api.ipify.org")
response2 = session.get("https://api.ipify.org")
print(response1.text == response2.text) # True - same IP

Session Rotation Strategies

Time-Based Rotation

import time
import uuid

class RotatingSession:
def __init__(self, username, password, rotation_minutes=5):
self.username = username
self.password = password
self.rotation_minutes = rotation_minutes
self.session_id = None
self.last_rotation = 0

def get_proxy(self):
current_time = time.time()

# Rotate session if needed
if current_time - self.last_rotation > self.rotation_minutes * 60:
self.session_id = uuid.uuid4().hex[:16]
self.last_rotation = current_time

return {
"http": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080",
"https": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080"
}

Request-Count Based Rotation

class CountBasedSession:
def __init__(self, username, password, requests_per_session=100):
self.username = username
self.password = password
self.requests_per_session = requests_per_session
self.request_count = 0
self.session_id = uuid.uuid4().hex[:16]

def get_proxy(self):
self.request_count += 1

if self.request_count > self.requests_per_session:
self.session_id = uuid.uuid4().hex[:16]
self.request_count = 1

return {
"http": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080",
"https": f"http://{self.username}-session-{self.session_id}:{self.password}@proxy.weproxies.com:1080"
}

Troubleshooting Sessions

Session IP Changed Unexpectedly

If your sticky session IP changes:

  1. Session expired - More than 10 min of inactivity
  2. IP became unavailable - Residential IP went offline
  3. Different session ID - Check for typos in session parameter

Verify Session is Working

# Run multiple times - should show same IP
for i in {1..5}; do
curl -x "http://wp_user-session-test123:password@proxy.weproxies.com:1080" \
https://api.ipify.org
echo ""
done

Next Steps