We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

damarev on 11/26/06


Tagged


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

meth
miziomon
vali29


setCookie


Published in: JavaScript 


  1. function setCookie( name, value, expires, path, domain, secure ) {
  2. var today = new Date();
  3. today.setTime( today.getTime() );
  4. if ( expires ) {
  5. expires = expires * 1000 * 60 * 60 * 24;
  6. }
  7. var expires_date = new Date( today.getTime() + (expires) );
  8. document.cookie = name+'='+escape( value ) +
  9. ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
  10. ( ( path ) ? ';path=' + path : '' ) +
  11. ( ( domain ) ? ';domain=' + domain : '' ) +
  12. ( ( secure ) ? ';secure' : '' );
  13. }

Report this snippet 

You need to login to post a comment.