summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/utils.js
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2015-03-19 14:08:17 +0100
committerJérome Maes <jem@openerp.com>2015-03-24 11:48:25 +0100
commitebc75e139512ff2f4bf20d2680aa52765c1c9513 (patch)
tree322993d7a9daa3fd1e4c61cd6c3c913775d04ee1 /addons/web/static/src/js/framework/utils.js
parent88f119314f9137f52bc6c01b97c85dfbfabf96ca (diff)
[IMP] web : add set_cookie in utils.js (framework) since the get_cookie method already exists. The set_cookie of session.js is now using the one from utils.js
Diffstat (limited to 'addons/web/static/src/js/framework/utils.js')
-rw-r--r--addons/web/static/src/js/framework/utils.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js
index 29a15d47a30..b13688aa538 100644
--- a/addons/web/static/src/js/framework/utils.js
+++ b/addons/web/static/src/js/framework/utils.js
@@ -223,6 +223,22 @@ function get_cookie (c_name) {
}
/**
+ * Create a cookie
+ * @param {String} name : the name of the cookie
+ * @param {String} value : the value stored in the cookie
+ * @param {Integer} ttl : time to live of the cookie in millis. -1 to erase the cookie.
+ */
+function set_cookie(name, value, ttl) {
+ ttl = ttl || 24*60*60*365;
+ document.cookie = [
+ name + '=' + value,
+ 'path=/',
+ 'max-age=' + ttl,
+ 'expires=' + new Date(new Date().getTime() + ttl*1000).toGMTString()
+ ].join(';');
+};
+
+/**
* Insert "thousands" separators in the provided number (which is actually
* a string)
*
@@ -368,6 +384,7 @@ return {
xml_to_str: xml_to_str,
Mutex: Mutex,
get_cookie: get_cookie,
+ set_cookie: set_cookie,
insert_thousand_seps: insert_thousand_seps,
is_bin_size: is_bin_size,
binary_to_binsize: binary_to_binsize,