The situation is such
there are two sites (domain.com, a.domain.com), with a single database, and so on.
If you log in and log out of the main domain, cookies are created and deleted for all domains.
If you log in with a.domain.com, then cookies are created for all domains, but they are not deleted. If you exit from the main domain, cookies remain on A :(
How to overcome it?
When you exit, I indicate that you need to leave all subdomains, putting a dot in front of the domain: .domain.com
public static function authorize($user) { if (self::isAuthorize()) { return; } $_SESSION[self::KEY_TOKEN] = $user->token; $_SESSION[self::KEY_ID] = $user->id; setcookie(self::KEY_TOKEN, $user->token, time() + 3600 * 24 * 365, '/', 'domain.com', self::isHttps(), self::HTTP_ONLY); setcookie(self::KEY_ID, $user->id, time() + 3600 * 24 * 365, '/', 'domain.com', self::isHttps(), self::HTTP_ONLY); } # выходим с авторизации public static function exit() { unset($_SESSION[self::KEY_TOKEN]); unset($_SESSION[self::KEY_ID]); setcookie(self::KEY_TOKEN, null, null, '/', '.domain.com', self::isHttps(), self::HTTP_ONLY); setcookie(self::KEY_ID, null, null, '/', '.domain.com', self::isHttps(), self::HTTP_ONLY); }
self::isHttps()andself::HTTP_ONLY? And if you try to put cookies on the domain.domain.com? - Artem Korsunov 2:49 pmперенаправлять обратно на сайт Аand catch an endless redirect - the logic will be very shaky in this case. - Goncharov Alexander