Posted By

abwaters on 06/07/09


Tagged

cookies


Versions (?)

Setting a Cookie in Javascript


 / Published in: JavaScript
 

URL: http://www.arachna.com/edu/tutorials/mini/cookies/javascript.html

  1. function setCookie() {
  2. var name = prompt('Name of the cookie');
  3. var value = prompt('Value of the cookie');
  4. var expires = prompt('Cookie expiration date');
  5. var path = prompt('Cookie path scope');
  6. var domain = prompt('Domain path scope');
  7. var secure = confirm('secure');
  8. var curCookie = name + "=" + escape(value) +
  9. ((expires) ? "; expires=" + expires.toGMTString() : "") +
  10. ((path) ? "; path=" + path : "") +
  11. ((domain) ? "; domain=" + domain : "") +
  12. ((secure) ? "; secure" : "");
  13. document.cookie = curCookie;
  14. return curCookie;
  15. }

Report this snippet  

You need to login to post a comment.