Documentation has been updated: see help center and changelog in one place.
⭐Explore
LogoLogo
Oxylabs dashboardContact usProduct
English
  • Documentation
  • Help center
  • Changelog
  • Overview
  • PROXIES
    • Integration Guides
      • Get IP Address for Integrations
      • Residential Proxies Guides
        • AdsPower
        • Android
        • ClonBrowser
        • Dolphin Anty
        • FoxyProxy
        • Ghost Browser
        • GoLogin
        • Helium Scraper
        • Incogniton
        • iOS
        • Kameleo
        • Lalicat Browser
        • MacOS
        • MoreLogin
        • MuLogin
        • Multilogin
        • Nstbrowser
        • Octoparse
        • Oxy® Proxy Extension for Chrome
        • ParseHub
        • Playwright
        • Proxifier
        • Puppeteer
        • Selenium
        • SEO Neo
        • SessionBox
        • Shadowrocket
        • Super Proxy
        • SwitchyOmega
        • Ubuntu
        • VMLogin
        • WebHarvy
        • Hidemyacc
      • ISP Proxies Guides
        • AdsPower
        • Android
        • Dolphin Anty
        • FoxyProxy
        • GoLogin
        • Incogniton
        • iOS
        • Lalicat Browser
        • MacOS
        • MoreLogin
        • MuLogin
        • Multilogin
        • Nstbrowser
        • Octoparse
        • Oxy® Proxy Extension for Chrome
        • Proxifier
        • SEO Neo
        • Shadowrocket
        • Sphere
        • Super Proxy
        • SwitchyOmega
        • Ubuntu
        • Hidemyacc
      • Mobile Proxies Guides
        • AdsPower
        • Android
        • ClonBrowser
        • Dolphin Anty
        • Ghost Browser
        • GoLogin
        • Helium Scraper
        • Incogniton
        • iOS
        • Kameleo
        • Lalicat Browser
        • MacOS
        • MoreLogin
        • MuLogin
        • Multilogin
        • Nstbrowser
        • Octoparse
        • Oxy® Proxy Extension for Chrome
        • ParseHub
        • Playwright
        • Proxifier
        • Puppeteer
        • Selenium
        • SEO Neo
        • SessionBox
        • Shadowrocket
        • SwitchyOmega
        • Ubuntu
        • VMLogin
        • WebHarvy
      • Dedicated Datacenter Proxies Guides
        • Enterprise
          • Dolphin Anty
          • FoxyProxy
          • GoLogin
          • Lalicat Browser
          • MoreLogin
          • MuLogin
          • Nstbrowser
          • Octoparse
          • Oxy® Proxy Extension for Chrome
          • Proxifier
          • SEO Neo
          • Shadowrocket
          • Sphere
          • Super Proxy
          • SwitchyOmega
          • Ubuntu
          • Hidemyacc
        • Self-Service
          • Android
          • Dolphin Anty
          • FoxyProxy
          • GoLogin
          • iOS
          • Lalicat Browser
          • MacOS
          • MoreLogin
          • MuLogin
          • Nstbrowser
          • Octoparse
          • Oxy® Proxy Extension for Chrome
          • Proxifier
          • SEO Neo
          • Shadowrocket
          • Sphere
          • Super Proxy
          • SwitchyOmega
          • Ubuntu
          • Hidemyacc
      • Datacenter Proxies Guides
        • AdsPower
        • Android
        • Dolphin Anty
        • FoxyProxy
        • GoLogin
        • iOS
        • Lalicat Browser
        • MacOS
        • MoreLogin
        • MuLogin
        • Nstbrowser
        • Octoparse
        • Oxy® Proxy Extension for Chrome
        • Proxifier
        • SEO Neo
        • Shadowrocket
        • Super Proxy
        • SwitchyOmega
        • Ubuntu
        • Hidemyacc
    • Residential Proxies
      • Getting Started
      • Making Requests
        • Entry Node for China
      • Location Settings
        • Country
        • City
        • State
        • Continent
        • ZIP/Postal code
        • Coordinates
        • ASN Targeting
      • Session Control
        • Sticky Proxy Entry Nodes
      • Protocols
      • Whitelisting IPs
        • Requests with Whitelisted IPs
      • Endpoint Generator
      • Restricted Targets
      • Public API
      • Response Codes
    • ISP Proxies
      • Making Requests
      • Proxy List
      • Proxy Rotation
      • Location Settings
      • Protocols
      • Whitelisting IPs
      • Response Codes
      • Restricted Targets
      • Fair usage policy
    • Mobile Proxies
      • Getting Started
      • Making Requests
        • Entry Node for China
      • Location Settings
        • Country
        • City
        • State
        • Continent
        • Coordinates
        • ASN Targeting
      • Session Control
        • Sticky Proxy Entry Nodes
      • Protocols
      • Whitelisting IPs
      • Endpoint Generator
      • Restricted Targets
      • Public API
      • Response Codes
    • Datacenter Proxies
      • Proxy List
      • IP Control
      • Select Country
      • Protocols
      • Whitelisting
      • Response Codes
      • Restricted Targets
      • Fair usage policy
      • Free Datacenter IPs
    • Dedicated Datacenter Proxies
      • Enterprise
        • Getting Started
        • Proxy List
        • Making Requests
        • Protocols
        • Whitelisting IPs
          • Dashboard
          • RESTful
            • Getting Whitelisted IPs List
            • Adding a Whitelisted IP
            • Removing a Whitelisted IP
            • Saving Changes (5min Cooldown)
        • Datacenter Proxy API
        • Proxy Rotator - Optional
        • Response Codes
      • Self-Service
        • Getting Started
        • Making Requests
        • Proxy List
        • Proxy Rotation
        • Location Settings
        • Protocols
        • Whitelisting IPs
        • Response Codes
        • Restricted Targets
        • Fair usage policy
    • Dedicated ISP Proxies
      • Getting Started
      • Proxy List
      • Making Requests
      • Protocols
      • Whitelisting IPs (RESTful)
        • Getting Whitelisted IPs List
        • Adding a Whitelisted IP
        • Removing a Whitelisted IP
        • Saving Changes (5min Cooldown)
      • Proxy API
      • Proxy Rotator - Optional
      • Response Codes
  • Advanced proxy solutions
    • Web Unblocker
      • Getting Started
      • Making Requests
        • Session
        • Geo-location
        • Headers & Cookies
        • Custom status code
        • POST requests
      • Headless Browser
        • JavaScript rendering
        • Browser instructions (Beta)
          • List of instructions
      • Sample Response
      • Response Codes
      • Rate Limits
      • Migration Guides
        • From Bright Data Web Unlocker
      • Usage Statistics
      • Billing Information
  • VIDEO DATA
    • High-Bandwidth Proxies
      • YouTube Downloader (yt_dlp) integration
  • Video Data API
  • Scraping Solutions
    • Web Scraper API
      • Integration Methods
        • Realtime
        • Push-Pull
        • Proxy Endpoint
      • Features
        • Localization
          • Proxy Location
          • SERP Localization
          • E-Commerce Localization
          • Domain, Locale, Results Language
        • JS Rendering & Browser Control
          • JavaScript Rendering
          • Browser Instructions
            • List of instructions
          • Capturing network requests (Fetch/XHR)
        • Result Processing & Storage
          • Dedicated Parsers
          • Custom Parser
            • Getting started
            • Parsing instruction examples
            • List of functions
              • Function examples
          • Download Images
          • Cloud Storage
        • HTTP Context & Job Management
          • Headers, Cookies, Method
          • User Agent Type
          • Client Notes
        • Scheduler
      • Solutions for AI Workflows
        • Model Context Protocol (MCP)
        • LangChain
        • LlamaIndex
      • Targets
        • Google
          • Search
            • Web Search
            • AI Overviews
            • Image Search
            • News Search
            • Local Search
            • Reverse Image Search
            • Google Suggest
          • Ads Max
          • Shopping
            • Shopping Product
            • Shopping Search
            • Shopping Pricing
          • Trends: Explore
          • Travel: Hotels
          • Lens
          • URL
        • Amazon
          • Product
          • Search
          • Pricing
          • Sellers
          • Best Sellers
          • Reviews
          • Questions & Answers
          • URL
        • YouTube
          • YouTube Scraping Guide for AI
          • YouTube Search
          • YouTube Video Trainability
          • YouTube Metadata
          • YouTube Downloader
          • YouTube Transcript
        • Generic Target
        • Walmart
          • Search
          • Product
        • Ebay
        • Etsy
          • Search
          • Product
        • Bing
          • Search
          • URL
        • ChatGPT
        • North American E-Commerce
          • Best Buy
            • Search
            • Product
          • Kroger
            • Product
            • Search
            • URL
          • Lowe's
            • Search
            • Product
            • URL
          • Target
            • Search
            • Product
            • Category
          • Bed Bath & Beyond
          • Costco
          • Menards
          • Petco
          • Staples
          • Grainger
          • Instacart
        • European E-Commerce
          • Allegro
            • Search
            • Product
          • Idealo
          • Mediamarkt
          • Cdiscount
        • Asian E-Commerce
          • Alibaba
          • Aliexpress
          • Lazada
          • Rakuten
          • Tokopedia
          • Flipkart
          • Avnet
          • Indiamart
        • Latin American E-Commerce
          • Mercado Livre
          • Magazine Luiza
          • Falabella
          • Dcard
      • Restricted Targets
      • Response Codes
      • Usage and Billing
        • Usage Statistics
        • Traffic and Billing
        • Rate Limits
    • OxyCopilot
    • Unblocking Browser
      • Chrome
      • Firefox
      • Restricted Targets
      • Integration with MCP
      • Troubleshooting Guide
  • Dashboard
    • Teams
    • Billing Information
      • Accessing Billing Information
      • Managing Payment Methods
      • Updating Billing Information
      • Canceling a Subscription
    • IP Replacement
  • Guides for Scraper APIs
    • Python SDK
    • Go SDK
    • Forming Requests
    • Forming URLs
    • Using Postman
  • Useful links
    • Oxylabs Dashboard
    • Release Notes
    • Network status
    • Open Source Tools
      • Oxy Parser
      • Oxy Mouse
      • Web Scraper API Scheduler
    • Discord Community
    • GitHub
    • Scraping Experts
  • SUPPORT
    • FAQ
    • Have a Question?
Powered by GitBook
On this page
  • Establishing session
  • Session time

Was this helpful?

  1. PROXIES
  2. Mobile Proxies

Session Control

PreviousASN TargetingNextSticky Proxy Entry Nodes

Last updated 3 months ago

Was this helpful?

Establishing session

The session ID parameter allows you to keep the same IP address to run multiple requests. To reuse the same IP multiple times, use sessid parameter after username with randomly created alphanumeric string, for example, sessid-abcde12345.

The standard session time is 10 minutes or up to 60s of inactivity (no requests). After that, a new IP address is assigned automatically. To adjust desired session time please refer to Session time.

For example, your initial query with sessid-abcde12345 assigned proxy IP address 1.1.1.1. As long as you keep sending new requests with the same session ID and that IP address is online and available, the system will route your queries through 1.1.1.1. If you stop sending requests for 60 seconds or the IP address is no longer online, the system will assign a new proxy IP. Your next query with sessid-abcde12345 will be routed through a different IP address e.g. 1.1.1.2.

Credentials list example:

Example represents a list of credentials that establish different sessions.

customer-USERNAME-sessid-iqwcp:PASSWORD
customer-USERNAME-sessid-tevab:PASSWORD
customer-USERNAME-sessid-6drwn:PASSWORD
customer-USERNAME-sessid-7eh7g:PASSWORD
customer-USERNAME-sessid-z7cao:PASSWORD

Code example

In this example we are using German IP with sessid-abcde12345 in the username with the first request. All following requests will keep the same German IP with further queries:

curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE-sessid-abcde12345:PASSWORD" https://ip.oxylabs.io/location
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$country = 'DE';
$session = mt_rand();
$proxy = 'pr.oxylabs.io:7777';
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "customer-$username-cc-$country-sessid-$session:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
country = 'DE'
session = random.random()
entry = ('http://customer-%s-cc-%s-sessid-%s:%s@pr.oxylabs.io:7777' %
    (username, country, session, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
package example;

import java.io.*;
import java.util.Random;
import org.apache.http.HttpHost;
import org.apache.http.auth.*;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.*;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;

class Client {
    public static final String username = "USERNAME";
    public static final String password = "PASSWORD";
    public String session_id = Integer.toString(new Random().nextInt(Integer.MAX_VALUE));
    public CloseableHttpClient client;

    public Client(String country) {
        String login = "customer-"+username+(country!=null ? "-cc-"+country : "")
            +"-sessid-" + session_id;
        HttpHost entry_node = new HttpHost("pr.oxylabs.io:7777");
        CredentialsProvider credentials_provider = new BasicCredentialsProvider();
        credentials_provider.setCredentials(new AuthScope(entry_node),
            new UsernamePasswordCredentials(login, password));
        client = HttpClients.custom()
            .setConnectionManager(new BasicHttpClientConnectionManager())
            .setProxy(entry_node)
            .setDefaultCredentialsProvider(credentials_provider)
            .build();
    }

    public String request(String url) throws IOException {
        HttpGet request = new HttpGet(url);
        CloseableHttpResponse response = client.execute(request);
        try {
            return EntityUtils.toString(response.getEntity());
        } finally { response.close(); }
    }

    public void close() throws IOException { client.close(); }
}

public class Example {
    public static void main(String[] args) throws IOException {
        Client client = new Client("de");
        try {
            System.out.println(client.request("https://ip.oxylabs.io/location"));
        } finally { client.close(); }
    }
}
using System;
using System.Net;

class Client : WebClient
{
    public static string username = "USERNAME";
    public static string password = "PASSWORD";
    public string session_id = new Random().Next().ToString();

    public Client(string country_iso = null)
    {
        this.Proxy = new WebProxy("pr.oxylabs.io:7777");
        var login = "customer-"+username+(country_iso != null ? "-cc-"+country_iso : "")
            +"-sessid-"+session_id;
        this.Proxy.Credentials = new NetworkCredential(login, password);
    }

    protected override WebRequest GetWebRequest(Uri address)
    {
        var request = base.GetWebRequest(address) as HttpWebRequest;
        request.ConnectionGroupName = session_id;
        return request;
    }
}

class Example
{
    static void Main()
    {
        var client = new Client("de");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
}
require 'uri'
require 'net/http'
require 'net/https'

entry_node = 'pr.oxylabs.io'
entry_port = '7777'
username = 'USERNAME'
password = 'PASSWORD'
session_id = Random.rand(1000000)

uri = URI.parse("https://ip.oxylabs.io/location")
headers = {
    'Accept-Encoding' => 'gzip'
}

proxy = Net::HTTP::Proxy(entry_node, entry_port, "#{username}-cc-DE-sessid-#{session_id}", password)
http = proxy.new(uri.host,uri.port)

if uri.scheme == 'https'
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end

req = Net::HTTP::Get.new(uri.path, headers)

result = http.start do |con|
    con.request(req)
end

puts result.body

Session time

The sesstime parameter goes together with sessid, and allows you to prolong the session above 10 minutes or set a particular time for it.

You can use the sesstime parameter to maintain the same IP for up to 1440 minutes (24 hours). However, because the mobile proxy pool is dynamic, your connection may end sooner. If that happens, start a session with a new session parameter.

Session time parameter does not ensure that all your queries are finished by the end of the session. The session will expire within the time limit set, even if requests are not finished.

Credentials list example:

Example represents a list of credentials that establish different sessions with different sessions time (minutes).

customer-USERNAME-sessid-iqwcp-sesstime-5:PASSWORD
customer-USERNAME-sessid-tevab-sesstime-12:PASSWORD
customer-USERNAME-sessid-6drwn-sesstime-30:PASSWORD
customer-USERNAME-sessid-7eh7g-sesstime-60:PASSWORD
customer-USERNAME-sessid-z7cao-sesstime-1440:PASSWORD

Code example

We chose the same German IP as in the previous example, this time we are adding sessidstring and sesstime parameter for 7 minutes:

curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE-sessid-abcde12345-sesstime-7:PASSWORD" https://ip.oxylabs.io/location
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$country = 'DE';
$session = mt_rand();
$sesstime = 7;
$proxy = 'pr.oxylabs.io:7777';
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "customer-$username-cc-$country-sessid-$session-sesstime-$sesstime:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
country = 'DE'
session = random.random()
sesstime = 7
entry = ('http://customer-%s-cc-%s-sessid-%s-sesstime-%d:%s@pr.oxylabs.io:7777' %
    (username, country, city, session, sesstime, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
package example;

import java.io.*;
import java.util.Random;
import org.apache.http.HttpHost;
import org.apache.http.auth.*;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.fluent.Request;
import org.apache.http.client.methods.*;
import org.apache.http.impl.client.*;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;

class Client {
    public static final String username = "USERNAME";
    public static final String password = "PASSWORD";
    public String session_id = Integer.toString(new Random().nextInt(Integer.MAX_VALUE));
    public String sesstime = "7";
    public CloseableHttpClient client;

    public Client(String country) {
        String login = "customer-"+username+(country_iso != null ? "-cc-"+country_iso : "")+"-sessid-"+session_id+"-sesstime-" +sesstime;
        HttpHost entry_node = new HttpHost("pr.oxylabs.io:7777");
        CredentialsProvider credentials_provider = new BasicCredentialsProvider();
        credentials_provider.setCredentials(new AuthScope(entry_node),
            new UsernamePasswordCredentials(login, password));
        client = HttpClients.custom()
            .setConnectionManager(new BasicHttpClientConnectionManager())
            .setProxy(entry_node)
            .setDefaultCredentialsProvider(credentials_provider)
            .build();
    }

    public String request(String url) throws IOException {
        HttpGet request = new HttpGet(url);
        CloseableHttpResponse response = client.execute(request);
        try {
            return EntityUtils.toString(response.getEntity());
        } finally { response.close(); }
    }

    public void close() throws IOException { client.close(); }
}

public class Example {
    public static void main(String[] args) throws IOException {
        Client client = new Client("de");
        try {
            System.out.println(client.request("https://ip.oxylabs.io/location"));
        } finally { client.close(); }
    }
}
using System;
using System.Net;

class Client : WebClient
{
    public static string username = "USERNAME";
    public static string password = "PASSWORD";
    public string session_id = new Random().Next().ToString();

    public Client(string country_iso = null)
    {
        this.Proxy = new WebProxy("pr.oxylabs.io:7777");
        var login = "customer-"+username+(country_iso != null ? "-cc-"+country_iso : "")
            +"-sessid-"+session_id;
        this.Proxy.Credentials = new NetworkCredential(login, password);
    }

    protected override WebRequest GetWebRequest(Uri address)
    {
        var request = base.GetWebRequest(address) as HttpWebRequest;
        request.ConnectionGroupName = session_id;
        return request;
    }
}

class Example
{
    static void Main()
    {
        var client = new Client("de");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
}
require 'uri'
require 'net/http'
require 'net/https'

entry_node = 'pr.oxylabs.io'
entry_port = '7777'
username = 'USERNAME'
password = 'PASSWORD'
session_id = Random.rand(1000000)
sesstime = 7

uri = URI.parse("https://ip.oxylabs.io/location")
headers = {
    'Accept-Encoding' => 'gzip'
}

proxy = Net::HTTP::Proxy(entry_node, entry_port, "#{username}-cc-DE-sessid-#{session_id}-sesstime-#{sesstime}", password)
http = proxy.new(uri.host,uri.port)

if uri.scheme == 'https'
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end

req = Net::HTTP::Get.new(uri.path, headers)

result = http.start do |con|
    con.request(req)
end

puts result.body

To set up sticky proxy entry nodes, learn more here.

Session control