# Mojo.Model.Cookie

## Class Detail

Creates a cookie object with a particular name.

Note:

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.

### Parameters

- {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

### get()

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.

#### Parameters

- {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.

### remove()

Deletes this cookie.

Example

>     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");
>     Mojo.Log.info("cookie2 value = " + cookie2.get());

Yields in the log:

>     info: cookie2 value = This is my info.