Using sessions

Passing a session ID parameter in your zone username allows you to re-use the same IP (in the case of zones set up on the datacenter network) or mobile device (in the case of zones set up on the mobile network) across multiple requests.

This can be useful if you find a specific IP or mobile device works well for a particular website and you wish to re-use that IP or mobile device for future requests.

Example

A session ID can be any alphanumeric string up to 50 characters long. You should pass it in the session parameter of your zone username.

For example, if you choose the session ID mysession1, for a zone with ID ABCDEF, the zone request username would be:

zone-ABCDEF-session-mysession1

A full curl command to run a request against the Bytio IP-checking endpoint would be:

curl \
 --proxy http://proxy.bytio.com:8080 \
 --proxy-user zone-ABCDEF-session-mysession1:YOUR-API-KEY \
 --verbose \
 "https://ip.bytio.com"

Limitations

  • Sessions expire 15 minutes after the last request using that session was made. There is no way of changing this session time. If you want the session to stay alive longer, you’d need to send a small request through it at least once every 15 minutes.
  • There is no upper time limit for sessions however note the ending sessions behaviour should the IP or mobile device the session is bound to become unavailable.
  • Session IDs are unique to your Bytio user. This means if you have two team members on the same Bytio account and both make a request with the same session ID, two sessions will be created.
  • A session ID can be any alphanumeric string with a maximum length of 50.

Considerations when using sessions on the Mobile network

Mobile devices, due to their more limited thruput, are subject to physical connection limits - typically 30 concurrent connections per mobile device, but this does vary depending on network conditions.

In the case of these limits being reached Bytio will attempt to service your request using another mobile device in the same country.

Best practices

Sessions are a great way to re-use IPs or mobile devices that you identify as working well for a specific website. However you won’t know that a specific IP or mobile device works well until you’ve made an initial request.

It’s recommended to follow this pattern:

1

Run request with session ID

Run an initial request specifying a random session ID, that your code generates, in the session parameter of the zone username.

2

Inspect results and re-use or renew session ID

Inspect the results and, if your code determines the request as being successful, re-use that session ID in future requests. When your code identifies a request as having been blocked, generate a new random session ID and repeat the process.

Ending sessions

If the IP or mobile device the session is bound to becomes unavailable (for example, if the mobile device loses cellular coverage) then the session will be terminated and an HTTP 404 - Session not available response will be issued. You should create a new session ID to use for subsequent requests.

For more information see the response codes docs.