我正在尝试通过php在用户交互上设置cookie
function promo_signup () {
$ip = get_client_ip();
$entry = [
\'firstname\' => $_POST[\'firstname\'],
\'lastname\' => $_POST[\'lastname\'],
\'mail\' => $_POST[\'mail\'].\'@student.unisg.ch\',
\'state\' => $_POST[\'state\'],
\'time\' => time(),
\'ip\' => get_client_ip(),
];
$mailing = get_post_meta( get_page_by_path(\'data\')->ID, \'mailing\', true );
$mailing[\'promo\'][\'clean\'][$_POST[\'id\']] = $entry;
array_push($mailing[\'promo\'][\'all\'],$entry);
update_post_meta( get_page_by_path(\'data\')->ID, \'mailing\', $mailing );
setcookie(\'welcomeback\',ucfirst($_POST[\'firstname\']),strtotime(\'27 Feb 2017\'),\'/\');
}
函数的主要用途工作正常,setcookie()返回true。
但是,当我重新加载页面时,没有创建cookie get
if(isset($_COOKIE[\'welcomeback\'])) {
echo "welcome back";
}