| Server IP : 104.21.21.239 / Your IP : 216.73.216.114 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/banners/public_html/bway/pixel/ |
Upload File : |
<?php
/**
* Cookie Manager — Handles personalization cookies for pixel tracking.
*
* Replicates cookie logic from pixel-article.cfm lines 19-129.
* Cookies: MYARTICLES20228, MYINTERESTS20228, REGION2023
*/
class CookieManager
{
private const COOKIE_EXPIRY = 43200 * 60; // 43200 minutes = 30 days in seconds
/**
* Clear legacy cookie versions (from pixel-article.cfm lines 69-72).
*/
public static function clearLegacyCookies(): void
{
$legacy = ['MYARTICLES2020', 'MYARTICLES20221', 'MYARTICLES2021', 'MYINTERESTS20221'];
foreach ($legacy as $name) {
setcookie($name, '', time() - 3600, '/', COOKIE_DOMAIN);
}
}
/**
* Reset MYINTERESTS20228 if it exceeds 3000 chars (from pixel-article.cfm lines 19-22).
*/
public static function resetInterestsIfOversized(): void
{
if (isset($_COOKIE['MYINTERESTS20228']) && strlen($_COOKIE['MYINTERESTS20228']) > 3000) {
setcookie('MYINTERESTS20228', '', time() - 3600, '/', COOKIE_DOMAIN);
setcookie('MYINTERESTS20228', '', time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
unset($_COOKIE['MYINTERESTS20228']);
}
}
/**
* Update the rolling article history cookie (from pixel-article.cfm lines 74-86).
* Appends article ID if not already present. Resets if over 2000 chars.
*/
public static function updateArticleCookie(int $articleId): void
{
$idStr = (string)$articleId;
if (!isset($_COOKIE['MYARTICLES20228'])) {
setcookie('MYARTICLES20228', $idStr, time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
$_COOKIE['MYARTICLES20228'] = $idStr;
return;
}
$current = $_COOKIE['MYARTICLES20228'];
// Reset if too long
if (strlen($current) > 2000) {
setcookie('MYARTICLES20228', $idStr, time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
$_COOKIE['MYARTICLES20228'] = $idStr;
return;
}
// Only add if not already present
if (strpos(',' . $current . ',', ',' . $idStr . ',') === false) {
$newValue = $current . ',' . $idStr;
setcookie('MYARTICLES20228', $newValue, time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
$_COOKIE['MYARTICLES20228'] = $newValue;
}
}
/**
* Update the interests cookie with a topic/production name.
* Format: comma-separated quoted strings like "Hamilton","Wicked"
* (from pixel-article.cfm lines 107-128)
*/
public static function updateInterestsCookie(string $topicName): void
{
if ($topicName === '') {
return;
}
if (isset($_COOKIE['MYINTERESTS20228'])) {
$current = $_COOKIE['MYINTERESTS20228'];
// Only add if not already present
if (stripos($current, $topicName) === false) {
$newValue = $current . ',"' . $topicName . '"';
setcookie('MYINTERESTS20228', $newValue, time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
$_COOKIE['MYINTERESTS20228'] = $newValue;
}
} else {
$newValue = '"' . $topicName . '"';
setcookie('MYINTERESTS20228', $newValue, time() + self::COOKIE_EXPIRY, '/', COOKIE_DOMAIN);
$_COOKIE['MYINTERESTS20228'] = $newValue;
}
}
/**
* Set the region cookie (from sitepixel.cfm line 14).
* Uses a very long expiry ("NEVER" in CF = persistent).
*/
public static function setRegionCookie(int $regionId): void
{
// 10 years ≈ "NEVER" expiry in ColdFusion
setcookie('REGION2023', (string)$regionId, time() + (10 * 365 * 86400), '/', COOKIE_DOMAIN);
}
}