gpt4 book ai didi

javascript - 跟踪服务器上的站点访问 - Meteor 中未定义的 session 变量

转载 作者:行者123 更新时间:2023-11-30 00:13:25 24 4
gpt4 key购买 nike

我尝试使用服务器端方法来设置 session 变量。

Meteor.methods({
'countvisit':function(){
var count=mydict;
count=count+1;
console.log("another visit come. Totally "+ count.toString()+" view the site");
mydict=count;
Session.set("globalcount", mydict);
}
});

错误发生在 Session.set 上,我发现我无法在服务器端获取 Session。错误是:

I20160224-11:34:38.773(11)? another visit come. Totally 1 view the site
I20160224-11:34:38.774(11)? Exception while invoking method 'countvisit' ReferenceError: Session is not defined
I20160224-11:34:38.774(11)? at [object Object].Meteor.methods.countvisit (server/startup.js:12:7)
I20160224-11:34:38.774(11)? at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20160224-11:34:38.774(11)? at livedata_server.js:708:19
I20160224-11:34:38.774(11)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20160224-11:34:38.774(11)? at livedata_server.js:706:40
I20160224-11:34:38.775(11)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20160224-11:34:38.775(11)? at livedata_server.js:704:46
I20160224-11:34:38.775(11)? at tryCallTwo (C:\Users\sheng\AppData\Local\.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promise\lib\core.js:45:5)
I20160224-11:34:38.775(11)? at doResolve (C:\Users\sheng\AppData\Local\.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promise\lib\core.js:171:13)
I20160224-11:34:38.775(11)? at new Promise (C:\Users\sheng\AppData\Local\.meteor\packages\promise\0.5.1\npm\node_modules\meteor-promise\node_modules\promise\lib\core.js:65:3)

如何在服务器上的 Meteor.methods() 中设置 session 变量?

最佳答案

看起来您正在记录客户端和服务器上的页面 View 。最好的方法实际上是将其保存到 mongo 中并将其发布回客户端

关于javascript - 跟踪服务器上的站点访问 - Meteor 中未定义的 session 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35591170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com