> For the complete documentation index, see [llms.txt](https://docs.ipwo.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipwo.net/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/session-bu-sheng-xiao.md).

# Session 不生效

如果使用 Session（粘性会话）后发现：

```
IP 没有固定
每次请求 IP 都在变化
Session 无效果
```

通常表示：

```
粘性会话未正确配置或未生效
```

***

### 一、Session 的作用

Session 用于：

```
让同一个用户尽量使用同一个出口 IP
```

常见场景：

* [TikTok 账号](/ying-yong-chang-jing/tiktok-yun-ying.md)
* [Facebook 广告](/ying-yong-chang-jing/facebook-guang-gao.md)
* [Amazon 店铺](/ying-yong-chang-jing/amazon-dian-pu-guan-li.md)
* [多账号运营](/ying-yong-chang-jing/duo-zhang-hao-guan-li.md)

***

### 二、常见原因

#### 1. Session 参数未正确写入

错误示例：

```
username_custom_zone_us
```

（未带 session）

***

#### 正确示例

```bash
username_custom_zone_us_session_abc123
```

***

#### 2. Session 每次都在变化

如果你每次请求都生成：

```
不同 session ID
```

系统会认为是不同用户，自然不会固定 IP。

***

#### 3. Session 已过期

部分 Session：

```
有时间限制或生命周期
```

过期后会重新分配 IP。

***

#### 4. 目标国家/节点切换

如果你在请求中切换：

* 国家
* zone
* 线路

Session 可能失效。

***

#### 5. 使用方式不一致

例如：

* curl 用了 session
* 代码请求没用 session

导致“看起来不生效”。

***

### 三、正确测试方式

#### cURL 示例

```bash
curl -x http://us.ipwo.net:7878 -U username_custom_zone_us_session_abc123:password http://ipinfo.io
```

***

#### 测试方法

连续请求：

```
多次访问同一个 session
```

观察 IP 是否保持一致。

***

### 四、推荐排查流程

```
1. 检查 session 是否正确拼接
↓
2. 确认 session 是否固定不变
↓
3. curl 测试
↓
4. 检查是否切换国家/zone
↓
5. 对比 IP 是否一致
```

***

### 五、如何正确使用 Session

#### ✔ 推荐方式

```
一个账号 = 一个 session = 一个 IP
```

***

#### ✔ 示例结构

```
账号A → session_A → IP_A
账号B → session_B → IP_B
```

***

#### ❌ 错误方式

* 多账号共用 session
* session 随机生成
* session + IP 频繁切换

***

### 六、开发建议

建议：

* 固定 session ID
* 控制生命周期
* 配合粘性代理使用
* 避免频繁更换参数

***

### 七、相关文章

* [什么是粘性会话](/dai-li-ji-chu-zhi-shi/shen-me-shi-nian-xing-hui-hua.md)
* [什么是轮换 IP](/dai-li-ji-chu-zhi-shi/shen-me-shi-lun-huan-ip.md)
* [IP 不生效](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/ip-bu-sheng-xiao.md)
* [请求频率过高](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/qing-qiu-pinlguo-gao.md)
* [407 Proxy Authentication Required](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/407-proxy-authentication-required.md)
* [如何降低封禁风险](/dai-li-ji-chu-zhi-shi/ru-he-jiang-di-feng-jin-feng-xian.md)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ipwo.net/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/session-bu-sheng-xiao.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
