Contents

setItem

Associates the given data with the given key.

Declaration

void setItem(
    in String key, 
    in String data
);
void setItem(
    DOMString key, 
    DOMString data
);

Parameters

  • key:

    A String object containing the key associated with the data to be saved.

  • data:

    A String object containing the data to be stored.

Discussion

The setItem function first checks whether the given key already exists in the storage. If it does not, then the key and associated value are stored. If the key already exists and the data in storage is different than the data being passed, the new data is saved to storage.

See Also

Accessing Key-Value Pair Information