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.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.util.Cookies"></div>/**
16 * @class Ext.util.Cookies
17 * Utility class for managing and interacting with cookies.
21 <div id="method-Ext.util.Cookies-set"></div>/**
22 * Create a cookie with the specified name and value. Additional settings
23 * for the cookie may be optionally specified (for example: expiration,
24 * access restriction, SSL).
25 * @param {String} name The name of the cookie to set.
26 * @param {Mixed} value The value to set for the cookie.
27 * @param {Object} expires (Optional) Specify an expiration date the
28 * cookie is to persist until. Note that the specified Date object will
29 * be converted to Greenwich Mean Time (GMT).
30 * @param {String} path (Optional) Setting a path on the cookie restricts
31 * access to pages that match that path. Defaults to all pages (<tt>'/'</tt>).
32 * @param {String} domain (Optional) Setting a domain restricts access to
33 * pages on a given domain (typically used to allow cookie access across
34 * subdomains). For example, "extjs.com" will create a cookie that can be
35 * accessed from any subdomain of extjs.com, including www.extjs.com,
36 * support.extjs.com, etc.
37 * @param {Boolean} secure (Optional) Specify true to indicate that the cookie
38 * should only be accessible via SSL on a page using the HTTPS protocol.
39 * Defaults to <tt>false</tt>. Note that this will only work if the page
40 * calling this code uses the HTTPS protocol, otherwise the cookie will be
41 * created with default options.
43 set : function(name, value){
45 var argc = arguments.length;
46 var expires = (argc > 2) ? argv[2] : null;
47 var path = (argc > 3) ? argv[3] : '/';
48 var domain = (argc > 4) ? argv[4] : null;
49 var secure = (argc > 5) ? argv[5] : false;
50 document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
53 <div id="method-Ext.util.Cookies-get"></div>/**
54 * Retrieves cookies that are accessible by the current page. If a cookie
55 * does not exist, <code>get()</code> returns <tt>null</tt>. The following
56 * example retrieves the cookie called "valid" and stores the String value
57 * in the variable <tt>validStatus</tt>.
59 * var validStatus = Ext.util.Cookies.get("valid");
61 * @param {String} name The name of the cookie to get
62 * @return {Mixed} Returns the cookie value for the specified name;
63 * null if the cookie name does not exist.
67 var alen = arg.length;
68 var clen = document.cookie.length;
73 if(document.cookie.substring(i, j) == arg){
74 return Ext.util.Cookies.getCookieVal(j);
76 i = document.cookie.indexOf(" ", i) + 1;
84 <div id="method-Ext.util.Cookies-clear"></div>/**
85 * Removes a cookie with the provided name from the browser
86 * if found by setting its expiration date to sometime in the past.
87 * @param {String} name The name of the cookie to remove
89 clear : function(name){
90 if(Ext.util.Cookies.get(name)){
91 document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
97 getCookieVal : function(offset){
98 var endstr = document.cookie.indexOf(";", offset);
100 endstr = document.cookie.length;
102 return unescape(document.cookie.substring(offset, endstr));