Страница 1 из 1

Не работают cookies

Добавлено: 28 сен 2017, 09:56
pol_ar
Добрый день.
Сайт на PHP 5.3, js-скрипт пытается сохранить в куках выбранный пользователем город.
Делается следующее обращение к функции setCookie:
function setCookie(name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

cityid = 'muhosransk';
setCookie('city', cityid, 'Mon, 01-Jan-2018 00:00:00 GMT', '/', 'sitename.ru');
location.reload(true);
Этот фрагмент кода на хостинге записывает в куки city. Этот же код на openserver не пишет в куки ничего. Этот же код не работает и на денвере. В чем может быть причина? В какую сторону копать?

Re: Не работают cookies

Добавлено: 05 окт 2017, 09:08
pol_ar
Only hosts within the specified domain can set a cookie for a domain and domains must have at least two (2) or three (3) periods in them to prevent domains of the form: “.com”, “.edu”, and “va.us”. Any domain that fails within one of the seven special top level domains listed below only require two periods. Any other domain requires at least three. The seven special top level domains are: “COM”, “EDU”, “NET”, “ORG”, “GOV”, “MIL”, and “INT”.

http://web-notes.ru/2008/07/cookies_wit ... l_domains/