javascript - Js cookies : SyntaxError: missing ) after argument list -


the error thrown when set cookie date :

var cookie = {      setcookie: function(name, value, expdate) {         'use strict';          var str = encodeuricomponent(name) + '=' + encodeuricomponent(value);         str +=';expires=' + expdate.toutcstring();         alert("in");         console.log(expdate.toutcstring());         document.cookie = str;     } // end of setcookie() function  };  window.onload = function() {     'use strict';    cookie.setcookie('username', 'john', mon 29 aug 2016 11:40:00 utc ); // date }; 

but doesn't if use number of days :

var cookie = {      setcookie: function(name, value, numdays) {         'use strict';           var cookiedate = new date();        cookiedate.setdate(cookiedate.getdate() + numdays);          var str = encodeuricomponent(name) + '=' + encodeuricomponent(value);         str +=';expires=' + cookiedate.togmtstring();         alert("in");         console.log(cookiedate.togmtstring());         document.cookie = str;     } // end of setcookie() function  };  window.onload = function() {     'use strict';    cookie.setcookie('username', 'john', 1 ); // day }; 

i respected format expected official doc. what's going on here? thanks,

you need follow debugger. points line:

cookie.setcookie('username', 'john', mon 29 aug 2016 11:40:00 utc ); 

mon 29 aug 2016 11:40:00 utc not valid javascript. maybe meant in quotes string.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -