# \GatewayWorker\Lib\Gateway::setSession
## 說明:
~~~
void Gateway::setSession(string $client_id, array $session);
~~~
(要求Gateway版本>=2.0.5)
設置某個client_id對應的session。如果對應client_id已經下線或者不存在,則會被忽略。
## 注意:
不要$_SESSION賦值與Gateway::setSession同時操作同一個$client_id,可能會造成session值與預期效果不符。操作當前用戶用$_SESSION['xx']=xxx方式賦值即可,操作其他用戶session可以使用Gateway::setSession接口。
## 參數
* $client_id
客戶端的client_id
* $session
要設置的session數組
## 返回值
無返回
## 范例
~~~
use \GatewayWorker\Lib\Gateway;
class Events
{
...
public onMessage($client_id, $message)
{
Gateway::setSession($client_id, array('key1'=>'value1', 'key2'=>'value2'));
}
...
}
~~~
- 快速入門
- 魔際客服系統V1.0簡介
- 新手上路
- 注冊并創建應用
- 通信過程及聊天記錄保存
- 實時消息回調
- Lib/Geteway類提供的接口
- sendToAll
- sendToClient
- closeClient
- isOnline
- bindUid
- unbindUid
- isUidOnline
- getClientIdByUid
- getUidByClientId
- sendToUid
- joinGroup
- leaveGroup
- sendToGroup
- getClientCountByGroup
- getClientSessionsByGroup
- getAllClientCount
- getAllClientSessions
- setSession
- updateSession
- getSession
- 服務端集成
- 入門
- 用戶體系集成
- 聊天記錄
- 文件上傳下載
- 發送消息
- 群組管理
- 聊天室管理
- 應用管理
- Web IM集成
- Web IM 介紹
- 集成方式
- Web SDK基礎功能
- 消息
- 好友管理
- 群組管理
- 聊天室管理
- 微信小程序 Demo
- Web SDK API Doc
- Web IM SDK 更新日志
- React Native集成
- React Native Demo 介紹