在Meteor.js中查找当前会话ID [英] Find the Current Session Id in Meteor.js

查看:71
本文介绍了在Meteor.js中查找当前会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在客户端上找到当前的会话ID?

How do you find the current Session Id on the client?

我能够得到似乎是最后一个会话ID,而不是当前的会话ID。

I am able to get what seems like the last session id, not the current session id.

console.log(Meteor.default_connection._lastSessionId)


推荐答案

这个措辞有点令人困惑,但 _lastSessionId 是当前的会话ID。

The wording for this is a bit confusing, but _lastSessionId is the current session id.

它只被调用,因为如果客户端断开连接并寻求重新连接,则需要使用上一个会话ID重新建立会话。

It is only called this because if the client is disconnected and seeks to reconnect it wants to re-establish the session with the last session id.

客户端将重新连接如下消息:

The client would reconnect with a message like this :

{"msg": "connect ", "session": "ERoZSR3R3f8zBQ6Ry", "version": "pre1","support":["pre1"]}

会话使用lastSessionId值。然后,这用于重新建立先前的连接。

The session uses the lastSessionId value. This is then used to re-establish the previous connection.

这是唯一一种在重新连接时分配新会话ID的情况。该会话或服务器的会话已过期。

This is the only case where a new session id would be assigned on a reconnection. That or the session is expired off the server.

如果服务器重新启动,则刷新缓存并且它将不再识别会话,并且新的会话ID将是已分配。

If the server restarts it's cache is refreshed and it wouldn't recognize the session anymore, and a new session id would be assigned.

这篇关于在Meteor.js中查找当前会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆