How to use the cookie.serializeObject function in cookie

To help you get started, we’ve selected a few cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github williamcotton / universal-react / src / js / browser / session.js View on Github external
remove: function(key) {
      var cookies = cookie.parse(document.cookie);
      var sessionObject = JSON.parse(cookies["session"]);
      delete sessionObject[key];
      var sessionObjectJSON = JSON.stringify(sessionObject);
      cookies["session"] = sessionObjectJSON;
      document.cookie = cookie.serializeObject(cookies);
      return localStorage.setItem("session", sessionObjectJSON);
    },
    removeAll: function() {
github williamcotton / universal-react / src / js / browser / session.js View on Github external
set: function(key, value) {
      var sessionObjectJSON = localStorage.getItem("session") || "{}";
      var sessionObject = JSON.parse(sessionObjectJSON);
      if (typeof(sessionObject) != "object") {
        sessionObject = {};
      }
      sessionObject[key] = value;
      sessionObjectJSON = JSON.stringify(sessionObject);
      document.cookie = cookie.serializeObject({
        "session": sessionObjectJSON
      });
      return localStorage.setItem("session", sessionObjectJSON);
    },
    get: function(key) {