Cookie State Source

Provides a simple way of accessing your cookies. Useful when creating isomorphic applications.

var UserCookies = Marty.createStateSource({
  type: 'cookie',
  login: function (user) {
    this.set(user.id, true)
  },
  logout: function(id) {
    this.expire(id);
  }
  isLoggedIn: function (id) {
    return !!this.get(id);
  }
});
class UserCookies extends Marty.CookieStateSource {
  constructor(options) {
    super(options);
  }
  login(user) {
    this.set(user.id, true)
  },
  logout(id) {
    this.expire(id);
  }
  isLoggedIn(id) {
    return !!this.get(id);
  }
}

get(key)

Gets the item from the cookie the given key.

set(key, value)

Sets the value to the cookie with the given key.

expire(key)

Removes the key from the cookie.