Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: r52snip
Added: Nov 14, 2018 5:28 AM
Modified: Nov 14, 2018 5:29 AM
Views: 4
Tags: cookei js
  1. function setCookie(name,value,days) {
  2.     var expires = "";
  3.     if (days) {
  4.         var date = new Date();
  5.         date.setTime(date.getTime() + (days*24*60*60*1000));
  6.         expires = "; expires=" + date.toUTCString();
  7.     }
  8.     document.cookie = name + "=" + (value || "")  + expires + "; path=/";
  9. }
  10.  
  11. # usage setCookie('yourCookeiName','yourCookeiValue',7)