Skip to content

Instantly share code, notes, and snippets.

@kepek
Created September 4, 2012 08:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kepek/3618730 to your computer and use it in GitHub Desktop.
Save kepek/3618730 to your computer and use it in GitHub Desktop.
var
setCookie = function (c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString() + "; path=/");
document.cookie = c_name + "=" + c_value;
};
setCookie("BsiLanguage", "pl_PL", 90, "/");
@fatihacet
Copy link

document.cookie = 'BsiLanguage="pl_PL";" is the fastest way to add a cookie.

@fatihacet
Copy link

Ah sorry, second double quote must be single. Fixed code is below.

document.cookie = 'BsiLanguage="pl_PL";';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment