Link to home
Start Free TrialLog in
Avatar of SheppardDigital
SheppardDigital

asked on

Javascript cookies clear the next day

Hi, we're trying to set a cookie using javascript that doesn't expiry for at least 6 month.

We're using this function to set a cookie

function setCookie(name, value, seconds) {
 
      if (typeof(seconds) != 'undefined') {
            var date = new Date();
            date.setTime(date.getTime() + (seconds*1000));
            var expires = "; expires=" + date.toGMTString();
            } else {
            var expires = "";
            }
 
      document.cookie = name+"="+value+expires+"; path=/";
      }

and then this to initiate the cookie...
setCookie('resources_user_id',response,15778463);

The cookie seems to work ok until the next day when you log into the site and the cookie has been cleared.

Am I doing something wrong?
ASKER CERTIFIED SOLUTION
Avatar of Ivo Stoykov
Ivo Stoykov
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial