Skip to content Skip to sidebar Skip to footer

Create Cookie Javascript

I have to create a JS cookie when a user click a button, this cookie will remember him after 10 minutes with another popup. Example: and the

Solution 1:

You didn't mention the expires in cookie. The expires date should be UTC time string.

function setCookieMsg(name) {
     var date = new Date();
     date.setTime(date.getTime()+(600000));
     var expires = "; expires="+date.toUTCString();
     document.cookie = name + "=" + expires;
}

Post a Comment for "Create Cookie Javascript"