Class Detail

Creates a cookie object with a particular name.


When doing a get(), the current functionality will match prefixes of the cookie name, rather than the entire cookie. For example, cookie1 and cookie2 will look the same when trying to retrieve the value. This will be corrected in a future release of webOS.

For the time being, cookie names all need to start with different letters. Alternatively, use standard DOM methods for setting and getting cookies.


  • {String} cookieName - Name for the cookie
  • {Object} optionalDocument Optional - document in which to store the cookie. Defaults to the current document.

Method Summary

  • get()
  • put(objectToStore, expirationDate)
  • remove()

Method Detail


Returns the object stored in this cookie, or undefined if no such cookie exists.

put(objectToStore, expirationDate)

Creates or updates the value of this cookie.


  • {Object} objectToStore - Object to store in a cookie. Must be something that can be that can be encoded in JSON.
  • {Date} expirationDate Optional - expiration date. Setting this to the current time or earlier will cause the cookie to be deleted.


Deletes this cookie.


var cookie1 = new Mojo.Model.Cookie("test");
var expiration = new Date("December 30, 2010 00:00:00");
cookie1.put("This is my info", expiration);

var cookie2 = new Mojo.Model.Cookie("test");"cookie2 value = " + cookie2.get());

Yields in the log:

info: cookie2 value = This is my info.