How do I delete or remove Session variables?

前端 未结 3 1902
故里飘歌
故里飘歌 2020-12-14 00:37

Meteor has a Session that provides a global object on the client that you can use to store an arbitrary set of key-value pairs. Use it to store things like the currently sel

3条回答
  •  無奈伤痛
    2020-12-14 01:07

    The disadvantage with using delete Session.keys['foo'] is that your template will not hot reload if the session key holds an array. For instance, if you are doing

    Template.mytempl.helpers({
        categories: function() {
            return Session.get('srch-categories')
        }
    })
    

    and in your template

    {{#if categories}}
        {{#each categories}}
            {{this}}
        {{/each}}
    {{/if}}
    

    And categories is an array, if you delete the session key, your template will continue to display the last value of categories.

提交回复
热议问题