Search code examples
javascriptparse-platformparse-cloud-code

How to save data to user session in Parse.com


After I log in the user on the backend (I use Parse.com CloudCode) I would like to save the uri to his avatar in his session. How would I do it in Parse.com. I know there is an object Parse.Session.current() but not sure how to use it.


Solution

  • Treat it just like other objects provided by parse.

    Parse.Session.current().then(function(session) {
        session.set("foo", "bar");
        session.save().then(function() {
            console.log(session.get("foo"));
        });
    });
    

    The session CLP should be set to allow this. (And the app must be setup to require revokable sessions).