Answer the question
In order to leave comments, you need to log in
Safari doesn't save cookies, what's wrong?
I made cookies on js in order to save the city that the user selects on my site. Works everywhere except Safari, what's wrong? Here is the code itself:
function getCookie(name) {
var cookie = " " + document.cookie;
var search = " " + name + "=";
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length > 0) {
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = cookie.indexOf(";", offset)
if (end == -1) {
end = cookie.length;
}
setStr = unescape(cookie.substring(offset, end));
}
}
return(setStr);
}
var townb = getCookie('town');
if(townb !== "" && townb !== null && townb !== "null" && townb !== " " && townb !== 0 && townb !== "0") {
$('.user-city-g').html('г. '+townb);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question