> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/proxies/mobile-proxies/session-control.md). Agents can also search and read this documentation through its [MCP server](https://developers.oxylabs.io/~gitbook/mcp).

# Session Control

Learn how to manage Mobile Proxy sessions to keep the same IP address across multiple requests and control session length and IP rotation.

## Set up a default session

The `sessid` parameter lets you route several requests through the same IP address. Add `sessid` after your `username` with a randomly generated alphanumeric string, for example `sessid-abcd1234`.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzrXw45naRpCZ0Ku9AjY1%2Fuploads%2FxR5NdybM3rjlbhAbPBZN%2Fsession-id.mp4?alt=media>" %}

For example, an initial request using `sessid-abcd1234` might be assigned the IP `1.1.1.1`. As long as you keep sending requests with the same session ID and that IP stays online, your queries continue to route through `1.1.1.1`. If the IP goes offline or the session reaches its maximum duration, the system assigns a new one, so your next request with `sessid-abcd1234` is routed through a different IP, such as `1.1.1.2`.

By default, a session lasts 10 minutes, or ends sooner if the IP goes offline – whichever comes first. Once that happens, a new IP address is assigned automatically. To change the session length, please refer to [**Extend session duration**](#extend-session-duration)**.**

### **Credentials list example:**

Example represents a list of credentials that establish different sessions.

```
customer-USERNAME-cc-DE-sessid-qwert:PASSWORD
customer-USERNAME-cc-US-sessid-asdfg:PASSWORD
customer-USERNAME-cc-GB-sessid-zxcvb:PASSWORD
```

### Code example

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

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE-sessid-abcd1234:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?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;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
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())
```

{% endtab %}

{% tab title="Java" %}

```java
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(); }
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
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"));
    }
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
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
```

{% endtab %}
{% endtabs %}

## Extend session duration

The `sesstime` parameter is used together with `sessid` to keep a session running longer than the default 10 minutes.

{% hint style="success" %}
**Note:** 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.
{% endhint %}

{% hint style="warning" %}
**Disclaimer:** The session time parameter does not guarantee that all of your requests finish before the session ends. The session expires once the time limit is reached, even if some requests are still in progress.
{% endhint %}

### **Credentials list example:**

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

```
customer-USERNAME-cc-DE-sessid-qwert-sesstime-10:PASSWORD
customer-USERNAME-cc-US-sessid-asdfg-sesstime-20:PASSWORD
customer-USERNAME-cc-GB-sessid-zxcvb-sesstime-30:PASSWORD
```

### Code example

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

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE-sessid-abcd1234-sesstime-7:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?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;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
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())
```

{% endtab %}

{% tab title="Java" %}

```java
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(); }
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
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"));
    }
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
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
```

{% endtab %}
{% endtabs %}

To set up sticky proxy entry nodes, learn more [**here**](broken://pages/wc7vlaxiJwl12yzI07HG).

## Control session IP rotation

The `sessid_oneip` parameter is an alternative to `sessid` for cases where you must keep the exact same IP for the entire session.

With a regular `sessid`, if the assigned exit node goes offline before the session time expires, the system automatically assigns a new IP and your session continues. With `sessid_oneip`, the session is bound to a single exit node: once that IP is no longer available, instead of rotating to a new one, the request fails with an HTTP `502` response. At that point, start a new session with a fresh `sessid_oneip` value. `sessid_oneip` can be combined with `sesstime` in the same way as `sessid`.

{% hint style="info" %}
**Note:** `sessid_oneip` is an optional alternative to `sessid`. The default `sessid` behavior (automatic rotation to a new IP when the exit node expires) is unchanged.
{% endhint %}

### **Credentials list example:**

The following credentials each establish a separate single-IP session, with a different country and session time:

```
customer-USERNAME-cc-DE-sessid_oneip-qwert-sesstime-10:PASSWORD
customer-USERNAME-cc-US-sessid_oneip-asdfg-sesstime-20:PASSWORD
customer-USERNAME-cc-GB-sessid_oneip-zxcvb-sesstime-30:PASSWORD
```

### Code example

This example uses a German (`DE`) IP with `sessid_oneip-qwert` and a `sesstime` of 10 minutes. The IP stays fixed for the session; if it becomes unavailable, the request returns HTTP `502` instead of rotating:

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-DE-sessid_oneip-qwert-sesstime-10:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}
{% endtabs %}

To use another language, take any `sessid` sample from the sections above and replace `sessid` with `sessid_oneip` in the login string.

## Sticky proxy entry nodes

The country-specific sticky proxy entry point will return the same IP with every new request while you use the same port. IP stickiness works for up to 10 minutes. After that, the IP is replaced with a new one.

You do not need to pass any additional parameters, just `customer-username:password`. If you have whitelisted IPs, you do not need to pass login credentials. Country-specific ports do not support city-level results.

Please see the dashboard for entry point information. Download a complete list of sticky entry points or see them in the table below.

{% file src="/files/9iaqY6oaoc8X7lW6q31e" %}

| <p>Random<br>pr.oxylabs.io:10000 - 49999</p>                                                                                                            | <p>US<br>us-pr.oxylabs.io:10001 - 19999</p>                                                                                                             | <p><img src="https://residential.oxylabs.io/0d067fa04caa8df594891aa2d10ce5fe.svg" alt="" data-size="line">Canada<br>ca-pr.oxylabs.io:30001 - 39999</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p>Great Britain<br>gb-pr.oxylabs.io:20001 - 29999</p>                                                                                                  | <p><img src="https://residential.oxylabs.io/ba83717811755fd02b806c07c79598aa.svg" alt="" data-size="line">Germany<br>de-pr.oxylabs.io:30001 - 39999</p> | <p><img src="https://residential.oxylabs.io/48ed3d318197d7c80ecd9009688330c4.svg" alt="" data-size="line">France<br>fr-pr.oxylabs.io:40001 - 49999</p> |
| <p>Spain<br>es-pr.oxylabs.io:10001 - 19999</p>                                                                                                          | <p>Italy<br>it-pr.oxylabs.io:20001 - 29999</p>                                                                                                          | <p>Sweden<br>se-pr.oxylabs.io:30001 - 39999</p>                                                                                                        |
| <p><img src="https://residential.oxylabs.io/9823f616a21e743394d856b6292bf8fd.svg" alt="" data-size="line">Greece<br>gr-pr.oxylabs.io:40001 - 49999</p>  | <p>Portugal<br>pt-pr.oxylabs.io:10001 - 19999</p>                                                                                                       | <p>Netherlands<br>nl-pr.oxylabs.io:20001 - 29999</p>                                                                                                   |
| <p><img src="https://residential.oxylabs.io/3911e782a75880578ad6aaf6c43cf4cc.svg" alt="" data-size="line">Belgium<br>be-pr.oxylabs.io:30001 - 39999</p> | <p>Russia<br>ru-pr.oxylabs.io:40001 - 49999</p>                                                                                                         | <p>Ukraine<br>ua-pr.oxylabs.io:10001 - 19999</p>                                                                                                       |
| <p>Poland<br>pl-pr.oxylabs.io:20001 - 29999</p>                                                                                                         | <p>Israel<br>il-pr.oxylabs.io:20001 - 29999</p>                                                                                                         | <p>Turkey<br>tr-pr.oxylabs.io:30001 - 39999</p>                                                                                                        |
| <p>Australia<br>au-pr.oxylabs.io:40001 - 49999</p>                                                                                                      | <p>Malaysia<br>my-pr.oxylabs.io:10001 - 19999</p>                                                                                                       | <p>Thailand<br>th-pr.oxylabs.io:20001 - 29999</p>                                                                                                      |
| <p>South Korea<br>kr-pr.oxylabs.io:30001 - 39999</p>                                                                                                    | <p>Japan<br>jp-pr.oxylabs.io:40001 - 49999</p>                                                                                                          | <p>Philippines<br>ph-pr.oxylabs.io:10001 - 19999</p>                                                                                                   |
| <p>Singapore<br>sg-pr.oxylabs.io:20001 - 29999</p>                                                                                                      | <p>China<br>cn-pr.oxylabs.io:30001 - 39999</p>                                                                                                          | <p>Hong Kong<br>hk-pr.oxylabs.io:40001 - 49999</p>                                                                                                     |
| <p>Taiwan<br>tw-pr.oxylabs.io:10001 - 19999</p>                                                                                                         | <p>India<br>in-pr.oxylabs.io:20001 - 29999</p>                                                                                                          | <p>Pakistan<br>pk-pr.oxylabs.io:30001 - 39999</p>                                                                                                      |
| <p>Iran<br>ir-pr.oxylabs.io:40001 - 49999</p>                                                                                                           | <p>Indonesia<br>id-pr.oxylabs.io:10001 - 19999</p>                                                                                                      | <p>Azerbaijan<br>az-pr.oxylabs.io:20001 - 29999</p>                                                                                                    |
| <p>Kazakhstan<br>kz-pr.oxylabs.io:30001 - 39999</p>                                                                                                     | <p>UAE<br>ae-pr.oxylabs.io:40001 - 49999</p>                                                                                                            | <p>Mexico<br>mx-pr.oxylabs.io:10001 - 19999</p>                                                                                                        |
| <p>Brazil<br>br-pr.oxylabs.io:20001 - 29999</p>                                                                                                         | <p>Argentina<br>ar-pr.oxylabs.io:30001 - 39999</p>                                                                                                      | <p>Chile<br>cl-pr.oxylabs.io:40001 - 49999</p>                                                                                                         |
| <p>Peru<br>pe-pr.oxylabs.io:10001 - 19999</p>                                                                                                           | <p>Ecuador<br>ec-pr.oxylabs.io:20001 - 29999</p>                                                                                                        | <p>Colombia<br>co-pr.oxylabs.io:30001 - 39999</p>                                                                                                      |
| <p>South Africa<br>za-pr.oxylabs.io:40001 - 49999</p>                                                                                                   | <p>Egypt<br>eg-pr.oxylabs.io:10001 - 19999</p>                                                                                                          | <p>Saudi Arabia<br>sa-pr.oxylabs.io:44001 - 44999</p>                                                                                                  |
| <p>Denmark<br>dk-pr.oxylabs.io:19001 - 19999</p>                                                                                                        | <p>Mali<br>ml-pr.oxylabs.io:13001 - 13999</p>                                                                                                           | <p>Cyprus<br>cy-pr.oxylabs.io:35001 - 35999</p>                                                                                                        |
| <p>Honduras<br>hn-pr.oxylabs.io:48001 - 48999</p>                                                                                                       | <p>Georgia<br>ge-pr.oxylabs.io:36001 - 36999</p>                                                                                                        | <p>Serbia<br>rs-pr.oxylabs.io:36001 - 36999</p>                                                                                                        |
| <p>Costa Rica<br>cr-pr.oxylabs.io:44001 - 44999</p>                                                                                                     | <p>Malta<br>mt-pr.oxylabs.io:30001 - 30999</p>                                                                                                          | <p>Haiti<br>ht-pr.oxylabs.io:47001 - 47999</p>                                                                                                         |
| <p>Senegal<br>sn-pr.oxylabs.io:19001 - 19999</p>                                                                                                        | <p>Slovenia<br>si-pr.oxylabs.io:38001 - 38999</p>                                                                                                       | <p>Cameroon<br>cm-pr.oxylabs.io:41001 - 41999</p>                                                                                                      |
| <p>Djibouti<br>dj-pr.oxylabs.io:46001 - 46999</p>                                                                                                       | <p>Angola<br>ao-pr.oxylabs.io:40001 - 40999</p>                                                                                                         | <p>Liberia<br>lr-pr.oxylabs.io:11001 - 11999</p>                                                                                                       |
| <p>Afghanistan<br>af-pr.oxylabs.io:28001 - 28999</p>                                                                                                    | <p>Bangladesh<br>bd-pr.oxylabs.io:30001 - 30999</p>                                                                                                     | <p>Bahamas<br>bs-pr.oxylabs.io:41001 - 41999</p>                                                                                                       |
| <p>Hungary<br>hu-pr.oxylabs.io:23001 - 23999</p>                                                                                                        | <p>Slovakia<br>sk-pr.oxylabs.io:37001 - 37999</p>                                                                                                       | <p>Dominica<br>dm-pr.oxylabs.io:46001 - 46999</p>                                                                                                      |
| <p>Kenya<br>ke-pr.oxylabs.io:10001 - 10999</p>                                                                                                          | <p>Bosnia and Herzegovina<br>ba-pr.oxylabs.io:13001 - 13999</p>                                                                                         | <p>Nigeria<br>ng-pr.oxylabs.io:18001 - 18999</p>                                                                                                       |
| <p>Qatar<br>qa-pr.oxylabs.io:43001 - 43999</p>                                                                                                          | <p>Yemen<br>ye-pr.oxylabs.io:48001 - 48999</p>                                                                                                          | <p>Belize<br>bz-pr.oxylabs.io:42001 - 42999</p>                                                                                                        |
| <p>Chad<br>td-pr.oxylabs.io:43001 - 43999</p>                                                                                                           | <p>Tunisia<br>tn-pr.oxylabs.io:25001 - 25999</p>                                                                                                        | <p>Zimbabwe<br>zw-pr.oxylabs.io:21001 - 21999</p>                                                                                                      |
| <p>Zambia<br>zm-pr.oxylabs.io:27001 - 27999</p>                                                                                                         | <p>Bahrain<br>bh-pr.oxylabs.io:29001 - 29999</p>                                                                                                        | <p>Austria<br>at-pr.oxylabs.io:11001 - 11999</p>                                                                                                       |
| <p>Ireland<br>ie-pr.oxylabs.io:25001 - 25999</p>                                                                                                        | <p>Norway<br>no-pr.oxylabs.io:34001 - 34999</p>                                                                                                         | <p>Ethiopia<br>et-pr.oxylabs.io:45001 - 45999</p>                                                                                                      |
| <p>Côte d'Ivoire<br>ci-pr.oxylabs.io:49001 - 49999</p>                                                                                                  | <p>Fiji<br>fj-pr.oxylabs.io:14001 - 14999</p>                                                                                                           | <p>South Sudan<br>ss-pr.oxylabs.io:22001 - 22999</p>                                                                                                   |
| <p>Jamaica<br>jm-pr.oxylabs.io:49001 - 49999</p>                                                                                                        | <p>Belarus<br>by-pr.oxylabs.io:15001 - 15999</p>                                                                                                        | <p>Finland<br>fi-pr.oxylabs.io:21001 - 21999</p>                                                                                                       |
| <p>Monaco<br>mc-pr.oxylabs.io:31001 - 31999</p>                                                                                                         | <p>New Zealand<br>nz-pr.oxylabs.io:15001 - 15999</p>                                                                                                    | <p>Turkmenistan<br>tm-pr.oxylabs.io:46001 - 46999</p>                                                                                                  |
| <p>Armenia<br>am-pr.oxylabs.io:31001 - 31999</p>                                                                                                        | <p>Iceland<br>is-pr.oxylabs.io:24001 - 24999</p>                                                                                                        | <p>Mauritania<br>mr-pr.oxylabs.io:14001 - 14999</p>                                                                                                    |
| <p>Czech Republic<br>cz-pr.oxylabs.io:18001 - 18999</p>                                                                                                 | <p>Venezuela<br>ve-pr.oxylabs.io:19001 - 19999</p>                                                                                                      | <p>Lebanon<br>lb-pr.oxylabs.io:39001 - 39999</p>                                                                                                       |
| <p>Mongolia<br>mn-pr.oxylabs.io:41001 - 41999</p>                                                                                                       | <p>Benin<br>bj-pr.oxylabs.io:44001 - 44999</p>                                                                                                          | <p>Sudan<br>sd-pr.oxylabs.io:23001 - 23999</p>                                                                                                         |
| <p>Jordan<br>jo-pr.oxylabs.io:38001 - 38999</p>                                                                                                         | <p>Estonia<br>ee-pr.oxylabs.io:20001 - 20999</p>                                                                                                        | <p>Paraguay<br>py-pr.oxylabs.io:17001 - 17999</p>                                                                                                      |
| <p>Central African Republic<br>cf-pr.oxylabs.io:42001 - 42999</p>                                                                                       | <p>Cambodia<br>kh-pr.oxylabs.io:34001 - 34999</p>                                                                                                       | <p>Panama<br>pa-pr.oxylabs.io:10001 - 10999</p>                                                                                                        |
| <p>Uruguay<br>uy-pr.oxylabs.io:18001 - 18999</p>                                                                                                        | <p>Ghana<br>gh-pr.oxylabs.io:48001 - 48999</p>                                                                                                          | <p>Uzbekistan<br>uz-pr.oxylabs.io:47001 - 47999</p>                                                                                                    |
| <p>Albania<br>al-pr.oxylabs.io:49001 - 49999</p>                                                                                                        | <p>Morocco<br>ma-pr.oxylabs.io:16001 - 16999</p>                                                                                                        | <p>Bhutan<br>bt-pr.oxylabs.io:32001 - 32999</p>                                                                                                        |
| <p>Mauritius<br>mu-pr.oxylabs.io:15001 - 15999</p>                                                                                                      | <p>Latvia<br>lv-pr.oxylabs.io:26001 - 26999</p>                                                                                                         | <p>Madagascar<br>mg-pr.oxylabs.io:12001 - 12999</p>                                                                                                    |
| <p>Lithuania<br>lt-pr.oxylabs.io:28001 - 28999</p>                                                                                                      | <p>Moldova<br>md-pr.oxylabs.io:32001 - 32999</p>                                                                                                        | <p>Montenegro<br>me-pr.oxylabs.io:33001 - 33999</p>                                                                                                    |
| <p>Romania<br>ro-pr.oxylabs.io:35001 - 35999</p>                                                                                                        | <p>Iraq<br>iq-pr.oxylabs.io:37001 - 37999</p>                                                                                                           | <p>Gambia<br>gm-pr.oxylabs.io:47001 - 47999</p>                                                                                                        |
| <p>Mozambique<br>mz-pr.oxylabs.io:17001 - 17999</p>                                                                                                     | <p>Croatia<br>hr-pr.oxylabs.io:16001 - 16999</p>                                                                                                        | <p>Puerto Rico<br>pr-pr.oxylabs.io:12001 - 12999</p>                                                                                                   |
| <p>Cuba<br>cu-pr.oxylabs.io:45001 - 45999</p>                                                                                                           | <p>Aruba<br>aw-pr.oxylabs.io:10001 - 10999</p>                                                                                                          | <p>Seychelles<br>sc-pr.oxylabs.io:20001 - 20999</p>                                                                                                    |
| <p>Macedonia<br>mk-pr.oxylabs.io:40001 - 40999</p>                                                                                                      | <p>Maldives<br>mv-pr.oxylabs.io:40001 - 40999</p>                                                                                                       | <p>Oman<br>om-pr.oxylabs.io:42001 - 42999</p>                                                                                                          |
| <p>Liechtenstein<br>li-pr.oxylabs.io:27001 - 27999</p>                                                                                                  | <p>Switzerland<br>ch-pr.oxylabs.io:39001 - 39999</p>                                                                                                    | <p>Bolivia<br>bo-pr.oxylabs.io:16001 - 16999</p>                                                                                                       |
| <p>Uganda<br>ug-pr.oxylabs.io:26001 - 26999</p>                                                                                                         | <p>Bulgaria<br>bg-pr.oxylabs.io:14001 - 14999</p>                                                                                                       | <p>Myanmar<br>mm-pr.oxylabs.io:33001 - 33999</p>                                                                                                       |
| <p>Andorra<br>ad-pr.oxylabs.io:10001 - 10999</p>                                                                                                        | <p>Togo<br>tg-pr.oxylabs.io:24001 - 24999</p>                                                                                                           | <p>British Virgin Islands<br>vg-pr.oxylabs.io:43001 - 43999</p>                                                                                        |
| <p>Trinidad and Tobago<br>tt-pr.oxylabs.io:13001 - 13999</p>                                                                                            | <p>Luxembourg<br>lu-pr.oxylabs.io:29001 - 29999</p>                                                                                                     | <p>​European Union</p><p>eu-pr.oxylabs.io:10001 - 29999</p>                                                                                            |

### Code examples

In this example, we run a query from a Turkish IP to `ip.oxylabs.io`. The same IP will stay for up to 10 minutes. We have chosen port `30001`. However, Turkey's sticky entry points cover ports from `30001` to `39999`.

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x tr-pr.oxylabs.io:30001 -U "customer-USERNAME:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$proxy = 'tr-pr.oxylabs.io:30001';
$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:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
entry = ('http://customer-%s:%s@tr-pr.oxylabs.io:30001' %
    (username, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
```

{% endtab %}

{% tab title="Java" %}

```java
package example;

import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpHost entry = new HttpHost("tr-pr.oxylabs.io", 30001);
        String query = Executor.newInstance()
            .auth(entry, "customer-USERNAME", "PASS")
            .execute(Request.Get("http://ip.oxylabs.io/location").viaProxy(entry))
            .returnContent().asString();
        System.out.println(query);
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var client = new WebClient();
        client.Proxy = new WebProxy("tr-pr.oxylabs.io:30001");
        client.Proxy.Credentials = new NetworkCredential("customer-USERNAME", "PASSWORD");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'

uri = URI.parse('https://ip.oxylabs.io/location')
proxy = Net::HTTP::Proxy('tr-pr.oxylabs.io', 30001, 'customer-USERNAME', 'PASSWORD')

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

result = proxy.start(uri.host,uri.port) do |http|
    http.request(req)
end

puts result.body
```

{% endtab %}
{% endtabs %}

## Lookalike sessions

The `sessid_similar_ip` parameter is an alternative to `sessid` for cases where you need a consistent network profile, but your session can continue on a new IP if the original one goes offline.

The first IP of the session becomes its **anchor**: its location, ISP and device platform (operating system) are saved. If the exit node goes offline before the session time expires, the session moves to another IP with the same **city, ISP and device platform** as the anchor, and keeps the same session ID and expiry time. If no matching IP is available, the request fails with an HTTP `502` response – the session never falls back to an unrelated IP. At that point, your next request with the same session ID starts a new session with a new anchor. `sessid_similar_ip` can be combined with `sesstime` in the same way as `sessid`. Location parameters (`cc`, `st`, `city`) apply only to the first IP.

{% hint style="info" %}
**Note:** `sessid_similar_ip` is an optional alternative to `sessid`. The default `sessid` behavior (automatic rotation to a new IP when the exit node expires) is unchanged.&#x20;
{% endhint %}

### **Credentials list example:**

The following credentials each establish a separate lookalike session, with a different location and session time:

```
customer-USERNAME-cc-US-city-los_angeles-sessid_similar_ip-qwert-sesstime-10:PASSWORD
customer-USERNAME-cc-DE-sessid_similar_ip-asdfg-sesstime-20:PASSWORD
customer-USERNAME-cc-GB-sessid_similar_ip-zxcvb-sesstime-30:PASSWORD
```

### Code examples

This example uses a Los Angeles (`US`) IP with `sessid_similar_ip-qwert` and a `sesstime` of 10 minutes. If the IP becomes unavailable, the session moves to an IP with the same city, ISP and device platform, or returns HTTP `502` if none is available:

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME-cc-US-city-los_angeles-sessid_similar_ip-qwert-sesstime-10:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}
{% endtabs %}

To use another language, take any `sessid` sample from the sections above and replace `sessid` with `sessid_similar_ip` in the login string.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/proxies/mobile-proxies/session-control.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
