> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pingnetwork.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions Control

By default, each request to our proxy server generates a new IP address. However, you can use session parameters to maintain the same IP address for multiple requests. This feature is useful for tasks that require a stable connection, such as web resources with session-based authentication.\
**Session Parameters**

We offer the `session` parameter to ensure you keep the same IP for all following requests.

### The`session`parameter

* A unique alphanumeric string, 6 to 15 characters long.
* Optimized for the highest overall success rate.
* May change IP address in favor of stability.
* Works with the `lifetime` parameter.

When specifying any geo targeting parameters, the first request will use the specified parameters, and all subsequent requests will use the same IP address. If you change the targeting while maintaining the same session, the IP address will remain the same.

### The`lifetime`parameter

* Specifies the duration for the `session` in minutes.
* Maximum value is 120 minutes.
* After the specified time, the IP address will change.
* If not specified, the session will last for 40 minutes by default.

If you specify a higher `lifetime` value than the maximum allowed, the request will return a 412 error code.

## **Examples**

Below are examples of using Sticky sessions in different programming languages: CURL, Python, and JavaScript.

<Tabs>
  <Tab title="CURL">
    ```bash theme={null}
    # Using session parameter
    curl -x USERNAME-session-abc123:PASSWORD@proxy.pingnetwork.io:7776 https://ipecho.net/plain

    # Using session with lifetime (60 minutes)
    curl -x USERNAME-session-abc123-lifetime-60:PASSWORD@proxy.pingnetwork.io:7776 https://ipecho.net/plain

    # Session with geo targeting
    curl -x USERNAME-cc-US-session-abc123:PASSWORD@proxy.pingnetwork.io:7776 https://ipecho.net/plain
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    # Using session parameter
    proxies = {
        'http': 'http://USERNAME-session-abc123:PASSWORD@proxy.pingnetwork.io:7776',
        'https': 'https://USERNAME-session-abc123:PASSWORD@proxy.pingnetwork.io:7777'
    }

    # Make multiple requests with the same IP
    for i in range(3):
        response = requests.get('https://ipecho.net/plain', proxies=proxies)
        print(f"Request {i+1}: {response.text.strip()}")

    # Using session with lifetime
    proxies_with_lifetime = {
        'http': 'http://USERNAME-session-xyz789-lifetime-30:PASSWORD@proxy.pingnetwork.io:7776',
        'https': 'https://USERNAME-session-xyz789-lifetime-30:PASSWORD@proxy.pingnetwork.io:7777'
    }

    response = requests.get('https://ipecho.net/plain', proxies=proxies_with_lifetime)
    print(f"Session with 30min lifetime: {response.text.strip()}")
    ```
  </Tab>

  <Tab title="Javascript">
    ```javascript theme={null}
    const axios = require('axios');
    const HttpsProxyAgent = require('https-proxy-agent');

    // Using session parameter
    const sessionProxyUrl = 'http://USERNAME-session-abc123:PASSWORD@proxy.pingnetwork.io:7776';
    const sessionAgent = new HttpsProxyAgent(sessionProxyUrl);

    // Make multiple requests with the same IP
    async function testSession() {
        for (let i = 0; i < 3; i++) {
            try {
                const response = await axios.get('https://ipecho.net/plain', { 
                    httpsAgent: sessionAgent 
                });
                console.log(`Request ${i+1}: ${response.data.trim()}`);
            } catch (error) {
                console.error(`Request ${i+1} failed:`, error.message);
            }
        }
    }

    // Using session with lifetime
    const lifetimeProxyUrl = 'http://USERNAME-session-xyz789-lifetime-45:PASSWORD@proxy.pingnetwork.io:7776';
    const lifetimeAgent = new HttpsProxyAgent(lifetimeProxyUrl);

    async function testSessionWithLifetime() {
        try {
            const response = await axios.get('https://ipecho.net/plain', { 
                httpsAgent: lifetimeAgent 
            });
            console.log(`Session with 45min lifetime: ${response.data.trim()}`);
        } catch (error) {
            console.error('Session request failed:', error.message);
        }
    }

    testSession();
    testSessionWithLifetime();
    ```
  </Tab>
</Tabs>
