3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
16 <div id="cls-Ext.state.CookieProvider"></div>/**
17 * @class Ext.state.CookieProvider
18 * @extends Ext.state.Provider
19 * The default Provider implementation which saves state via cookies.
22 var cp = new Ext.state.CookieProvider({
24 expires: new Date(new Date().getTime()+(1000*60*60*24*30)), //30 days
27 Ext.state.Manager.setProvider(cp);
29 * @cfg {String} path The path for which the cookie is active (defaults to root '/' which makes it active for all pages in the site)
30 * @cfg {Date} expires The cookie expiration date (defaults to 7 days from now)
31 * @cfg {String} domain The domain to save the cookie for. Note that you cannot specify a different domain than
32 * your page is on, but you can specify a sub-domain, or simply the domain itself like 'extjs.com' to include
33 * all sub-domains if you need to access cookies across different sub-domains (defaults to null which uses the same
34 * domain the page is running on including the 'www' like 'www.extjs.com')
35 * @cfg {Boolean} secure True if the site is using SSL (defaults to false)
37 * Create a new CookieProvider
38 * @param {Object} config The configuration object
40 Ext.state.CookieProvider = Ext.extend(Ext.state.Provider, {
42 constructor : function(config){
43 Ext.state.CookieProvider.superclass.constructor.call(this);
45 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
48 Ext.apply(this, config);
49 this.state = this.readCookies();
53 set : function(name, value){
54 if(typeof value == "undefined" || value === null){
58 this.setCookie(name, value);
59 Ext.state.CookieProvider.superclass.set.call(this, name, value);
63 clear : function(name){
64 this.clearCookie(name);
65 Ext.state.CookieProvider.superclass.clear.call(this, name);
69 readCookies : function(){
71 c = document.cookie + ";",
72 re = /\s?(.*?)=(.*?);/g,
76 while((matches = re.exec(c)) != null){
79 if(name && name.substring(0,3) == "ys-"){
80 cookies[name.substr(3)] = this.decodeValue(value);
87 setCookie : function(name, value){
88 document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
89 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
90 ((this.path == null) ? "" : ("; path=" + this.path)) +
91 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
92 ((this.secure == true) ? "; secure" : "");
96 clearCookie : function(name){
97 document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
98 ((this.path == null) ? "" : ("; path=" + this.path)) +
99 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
100 ((this.secure == true) ? "; secure" : "");