I already have a script that check for the cookies existence,
but i need it to get the cookies value so i can use it in a url like this:
var lang = cookievalue;
location.replace(window.location.protocol+"//"+document.domain+"/"+cookievalue+window.location.pathname);
so what would be the easiest way to simply get the value of a cookie through javascript, everything i’ve looked for seems to involve spliting the value and stuff,w hich is not necesary since theres simply only one value (en,fr,es etc)
Then, to get a value for a cookie named
my_cookie_name, you would usegetCookieValue('my_cookie_name').Also as an alternative, you can use the
jquery-cookieplugin. It’s very simple to use ($.cookie('my_cookie_name')) and lightweight.