code :
new Date( new Date().getTime()+(30 * 24*60*60*1000) ).toUTCString() ;
result :
"Fri, 29 Jul 2016 13:32:43 GMT"
code :
document.cookie = 'position.x=100; expires='+new Date( new Date().getTime()+(30 * 24*60*60*1000)).toUTCString() ;
code :
getCookie = function ( name ) { return document.cookie .split(';') .map(function(el) { c = el.split('=') ; return { 'name' : c[0], 'value' : c[1] }; }) .find(function(el) { return el.name == name ; }); };
code :
position = (function ( name ) { return document.cookie.split(';') .map(function(el) { c = el.split('=') ; return { 'name' : c[0], 'value' : c[1] }; }) .find(function(el) { return el.name == name ; }) .value ; })('position.x');
result :
"100"
code :
position_x = getCookie('position.x') ;
result :
Object {name: "position.x", value: "100"}