会话标识符


服务器为新连接生成唯一的 ID 并将其发送给客户端。 客户端和服务器保存会话状态。 当重新连接时,客户端发送其保存的会话状态的 ID,如果服务器也有该 ID 的状态,它可以同意使用它。 否则,服务器将创建新的会话。 请参阅 RFC 2246 了解更多信息,第 23 和 30 页\。

当发出 HTTPS 请求时,大多数网络浏览器都支持使用会话标识符恢复。

对于 Node.js,客户端等待 'session' 事件获取会话数据,并将数据提供给后续 tls.connect()session 选项以重用会话。 服务器必须为 'newSession''resumeSession' 事件实现句柄,以使用会话 ID 作为查找键来保存和恢复会话数据以重用会话。 要在负载均衡器或集群工作器之间重用会话,服务器必须在其会话处理程序中使用共享会话缓存(例如 Redis)。

Servers generate a unique ID for new connections and send it to the client. Clients and servers save the session state. When reconnecting, clients send the ID of their saved session state and if the server also has the state for that ID, it can agree to use it. Otherwise, the server will create a new session. See RFC 2246 for more information, page 23 and 30.

Resumption using session identifiers is supported by most web browsers when making HTTPS requests.

For Node.js, clients wait for the 'session' event to get the session data, and provide the data to the session option of a subsequent tls.connect() to reuse the session. Servers must implement handlers for the 'newSession' and 'resumeSession' events to save and restore the session data using the session ID as the lookup key to reuse sessions. To reuse sessions across load balancers or cluster workers, servers must use a shared session cache (such as Redis) in their session handlers.