我会知道如何在函数中设置特定的$_SESSION['element']
超时
目的是通过Web推送通知显示信息。
如果客户在48小时后回来,则会显示通知。
当前声明为$_SESSION['SpecialsProducts']
时,不显示该信息。
Tk。
我的代码
if (WEB_PUSH_SPECIAL == 'True') {
$special_products = $this->specialsProducts();
if (!empty($special_products) && $_SESSION['SpecialsProducts'] === false) {
$_SESSION['SpecialsProducts'] = true;
$message_products_special = $special_products;
$special_link = CLICSHOPPING::link(null, 'Products&Specials');
$message_products_special = json_encode($message_products_special);
$special_link = json_encode($special_link);
$output .= <<< JS
<script>
/* Begin PHP values */
var introduction = $introduction;
var message_products_special = $message_products_special;
var special_link = $special_link;
/* End PHP values */
Push.create(introduction, {
body: message_products_special,
icon: 'sources/images/logos/others/favicon.png',
timeout: 8000,
vibrate: [100, 100, 100],
onClick: function() {
window.location = special_link;
}
});
</script>
JS;
}
}
echo $output;
功能
public function specialsProducts() {
$this->db = Registry::get('Db');
if ($_SESSION['SpecialsProducts'] === false) {
$Qspecials = $$this->db->prepare('select count(specials_id) as count
from :table_specials
where status = 1
');
$Qspecials->execute();
if ($Qspecials->valueInt('count') > 0) {
$message = $this->getDef('module_web_push_text_specials');
}
}
Return $message;
}