How do you store data server side that is specific to a client in Meteor?

后端 未结 6 1371
北恋
北恋 2021-02-13 02:29

Express implements a server side session object that lets you store data specific to a client. How would you do the equivalent in Meteor?

strack recommended using a coll

6条回答
  •  一生所求
    2021-02-13 02:58

    One thing to note is that UserSession doesn't work for a user who has not logged in at the client. I faced this scenario, since I wanted creation of a new user's data object to be modified before saving to MongoDB. The modification was to add an attribute/field obtained from the URL path of current page (using Iron Route client side route). But I was receiving this error,

    "You cannot use UserSession methods when there is no user logged in."

    So if your use case is restricted to sharing data between client and server for a logged in user, UserSession package seems to do the job.

提交回复
热议问题