流星会议

编程入门 行业动态 更新时间:2024-10-28 16:20:17
本文介绍了流星会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

经过研究,似乎 Meteor 会话在刷新页面或在新选项卡中打开网站后重置,即它们不是通常的服务器端会话,而是类似于客户端的全局 javascript 变量.有些人建议使用 AmplifyJS,但我不确定它是否会像其他框架/语言中的常规会话一样工作,而且它是第三方库,所以在 Meteor 中使用会话有什么正常的方法,即保持用户-服务器上的具体数据?

After a research it seems that Meteor Sessions are reset after refreshing page or opening the website in new tab, i.e. they are not usual server-side sessions but something like global javascript variables on client-side. Some people advice to use AmplifyJS, but I'm not sure that it will work like usual session in other frameworks/languages and also it is a third party library, so is there any normal way to use sessions in Meteor, i.e. keep user-specific data on server?

目前我正在通过使用自定义集合来处理这个问题,但这不是一种理想的方法,因为需要手动从集合中删除过期值,这会带来额外的麻烦.

At this moment I'm handling that by using custom Collections, but it is not an ideal way of doing that because it is needed to remove expired values from Collection manually, which makes additional troubles.

推荐答案

是的,这是正确的.尽管名称 Session 与 cookie 完全不同,但它只是存储在哈希映射中的变量的反应形式

Yes this is correct. Despite the name Session is nothing like a cookie, but just a reactive form of a variable stored in a hashmap

要使数据跨选项卡保持持久性,您需要使用集合(因为这是跨选项卡被动共享数据的唯一方法)- Cookie 无法工作,因为它们无法响应,因为需要将数据发送到服务器在发生变化时通知客户端.目前确实没有其他方法,因为发布/订阅方法目前只能从集合中发送数据.

To keep data persistent across tabs you need to use a Collections (as this is the only way to reactively share data across tabs) - Cookies can't work because they can't be made reactive as data needs to be sent to the server to notify the client when there is a change. There really wouldn't be another way at the moment as the publish/subscribe methods can only send down data from collections at the moment.

您可以将您现在的设置与您的自定义集合一起使用.您可以使用服务器端 cron 作业删除过期数据(使用 Meteor.setInterval 或 Tom Coleman 的 cron.

You can use your setup you have now with your custom collection. You can use a server side cron job to remove expired data (either with Meteor.setInterval or Tom Coleman's cron.

更多推荐

流星会议

本文发布于:2023-10-31 05:35:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545161.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:流星   会议

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!