本文整理汇总了PHP中MAX_cookieClientCookieSet函数的典型用法代码示例。如果您正苦于以下问题:PHP MAX_cookieClientCookieSet函数的具体用法?PHP MAX_cookieClientCookieSet怎么用?PHP MAX_cookieClientCookieSet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MAX_cookieClientCookieSet函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MAX_cookieClientCookieFlush
function MAX_cookieClientCookieFlush()
{
$conf = $GLOBALS['_MAX']['CONF'];
$domain = !empty($conf['cookie']['domain']) ? $conf['cookie']['domain'] : null;
MAX_cookieSendP3PHeaders();
if (!empty($GLOBALS['_MAX']['COOKIE']['CACHE'])) {
reset($GLOBALS['_MAX']['COOKIE']['CACHE']);
while (list($name, $v) = each($GLOBALS['_MAX']['COOKIE']['CACHE'])) {
list($value, $expire) = $v;
if ($name == $conf['var']['viewerId']) {
MAX_cookieClientCookieSet($name, $value, $expire, '/', !empty($conf['cookie']['viewerIdDomain']) ? $conf['cookie']['viewerIdDomain'] : $domain);
} else {
MAX_cookieSet($name, $value, $expire, '/', $domain);
}
}
$GLOBALS['_MAX']['COOKIE']['CACHE'] = array();
}
$cookieNames = $GLOBALS['_MAX']['COOKIE']['LIMITATIONS']['arrCappingCookieNames'];
if (!is_array($cookieNames)) {
return;
}
$maxCookieSize = !empty($conf['cookie']['maxCookieSize']) ? $conf['cookie']['maxCookieSize'] : 2048;
foreach ($cookieNames as $cookieName) {
if (empty($_COOKIE["_{$cookieName}"])) {
continue;
}
switch ($cookieName) {
case $conf['var']['blockAd']:
case $conf['var']['blockCampaign']:
case $conf['var']['blockZone']:
$expire = _getTimeThirtyDaysFromNow();
break;
case $conf['var']['lastClick']:
case $conf['var']['lastView']:
case $conf['var']['capAd']:
case $conf['var']['capCampaign']:
case $conf['var']['capZone']:
$expire = _getTimeYearFromNow();
break;
case $conf['var']['sessionCapCampaign']:
case $conf['var']['sessionCapAd']:
case $conf['var']['sessionCapZone']:
$expire = 0;
break;
}
if (!empty($_COOKIE[$cookieName]) && is_array($_COOKIE[$cookieName])) {
$data = array();
foreach ($_COOKIE[$cookieName] as $adId => $value) {
$data[] = "{$adId}.{$value}";
}
while (strlen(implode('_', $data)) > $maxCookieSize) {
$data = array_slice($data, 1);
}
MAX_cookieSet($cookieName, implode('_', $data), $expire, '/', $domain);
}
}
}
示例2: MAX_cookieClientCookieFlush
function MAX_cookieClientCookieFlush()
{
$conf = $GLOBALS['_MAX']['CONF'];
MAX_cookieSendP3PHeaders();
if (!empty($GLOBALS['_MAX']['COOKIE']['CACHE'])) {
// Set cookies
reset($GLOBALS['_MAX']['COOKIE']['CACHE']);
while (list($name, $v) = each($GLOBALS['_MAX']['COOKIE']['CACHE'])) {
list($value, $expire) = $v;
// Treat the viewerId cookie differently, (always set in client)
if ($name == $conf['var']['viewerId']) {
MAX_cookieClientCookieSet($name, $value, $expire, '/', !empty($conf['cookie']['domain']) ? $conf['cookie']['domain'] : null);
} else {
MAX_cookieSet($name, $value, $expire, '/', !empty($conf['cookie']['domain']) ? $conf['cookie']['domain'] : null);
}
}
// Clear cache
$GLOBALS['_MAX']['COOKIE']['CACHE'] = array();
}
// Compact all individual cookies into packed except for any cookies for the current bannerid
// We only need to set these packed cookies if new capping data has been merged
$cookieNames = $GLOBALS['_MAX']['COOKIE']['LIMITATIONS']['arrCappingCookieNames'];
if (!is_array($cookieNames)) {
return;
}
// For each type of cookie, repack if necessary
foreach ($cookieNames as $cookieName) {
// We only need to write out the compacted cookie if a new item is to be inserted (or updated)
if (empty($_COOKIE["_{$cookieName}"])) {
continue;
}
switch ($cookieName) {
case $conf['var']['blockAd']:
case $conf['var']['blockCampaign']:
case $conf['var']['blockZone']:
$expire = _getTimeThirtyDaysFromNow();
break;
case $conf['var']['capAd']:
case $conf['var']['capCampaign']:
case $conf['var']['capZone']:
$expire = _getTimeYearFromNow();
break;
case $conf['var']['sessionCapCampaign']:
case $conf['var']['sessionCapAd']:
case $conf['var']['sessionCapZone']:
$expire = 0;
break;
}
if (!empty($_COOKIE[$cookieName]) && is_array($_COOKIE[$cookieName])) {
$data = array();
foreach ($_COOKIE[$cookieName] as $adId => $value) {
$data[] = "{$adId}.{$value}";
}
// RFC says that maximum cookie data length is 4096 bytes
// So we are assuming that 2048 will be valid in most browsers
// Discard oldest data until we are under the limit
while (strlen(implode('_', $data)) > 2048) {
$data = array_slice($data, 1);
}
MAX_cookieSet($cookieName, implode('_', $data), $expire, '/', !empty($conf['cookie']['domain']) ? $conf['cookie']['domain'] : null);
}
}
}