且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

signalR维护用户连接ID

更新时间:2023-11-28 11:50:58

的到期日期为饼干应该是UTC的字符串(你不这样做,那么最有可能的服务器正在处理您的Cookie为过期)。更改code是这样的:

The expire date for the cookie should be UTC string (you are not doing this, so most probably the server is treating your cookie as expired). Change your code like this:

var cValue = escape(value) + ((exdays==null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = cName + "=" + cValue;

或者,你可能只是使用的jQuery插件的Cookie为设置的cookie。

更新

此外cookie的名称在您提供的code为inconsitent。您正在设置与名称的CookieuserConnectionid,但试图通过名字来访问srconnectionid。请检查你还没有出现拼写错误。

Also the name of cookie is inconsitent in the code you have provided. You are setting the cookie with name 'userConnectionid' but trying to access by name 'srconnectionid'. Please check if you haven't made a spelling error there.