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.2.1
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 = function(config){
41 Ext.state.CookieProvider.superclass.constructor.call(this);
43 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
46 Ext.apply(this, config);
47 this.state = this.readCookies();
50 Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
52 set : function(name, value){
53 if(typeof value == "undefined" || value === null){
57 this.setCookie(name, value);
58 Ext.state.CookieProvider.superclass.set.call(this, name, value);
62 clear : function(name){
63 this.clearCookie(name);
64 Ext.state.CookieProvider.superclass.clear.call(this, name);
68 readCookies : function(){
70 var c = document.cookie + ";";
71 var re = /\s?(.*?)=(.*?);/g;
73 while((matches = re.exec(c)) != null){
74 var name = matches[1];
75 var value = matches[2];
76 if(name && name.substring(0,3) == "ys-"){
77 cookies[name.substr(3)] = this.decodeValue(value);
84 setCookie : function(name, value){
85 document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
86 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
87 ((this.path == null) ? "" : ("; path=" + this.path)) +
88 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
89 ((this.secure == true) ? "; secure" : "");
93 clearCookie : function(name){
94 document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
95 ((this.path == null) ? "" : ("; path=" + this.path)) +
96 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
97 ((this.secure == true) ? "; secure" : "");