ExtJs operation Cookie

Source: Internet
Author: User

ExtJs operation Cookie

The ExtJs Cookie operation method is very simple. There are only three methods:

Clear (name): clear the value set for name.

Set (name, value): set the value of name to value.

Get (name): get the value set for name.

The following is an example:

Ext. onReady (function () {var stringtest = "this is a string"; var obj = {name: "this is name", description: "this id description"}; Ext. util. cookies. set ("test1", stringtest); Ext. util. cookies. set ("test2", Ext. encode (obj); Ext. msg. alert ("prompt", "first parameter:" + Ext. util. cookies. get ("test1") + "\ n second parameter string format:" + Ext. util. cookies. get ("test2") + "\ n get the second string name attribute value:" + Ext. decode (Ext. util. cookies. get ("test2 ")). name );});
Note that cookies can only store strings, but cannot store objects. To store objects, use Ext first. the encode () method converts a complex object structure to a string, but you need to use Ext to retrieve the string. decode () to convert the string to the original object type. If the object also contains an object, the toString () method of the internal object will be called when the encode is used. The stored type is "object" and the data type is not stored, when the decode method is called, the object is converted back to a string instead of the original object.

The running result of the preceding example is as follows:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.