我正在开发一个新产品/网站,其中主页(不是子页面)应该为访问者关闭,直到网站启动。此次推出的最新应读出这样的URL:使Cookie根据URL变量过期PHP
website.com/some-subpage?launch=0421
在这个例子中的网页应该是从4月21(21)(04)访问者访问。
在此,我想这样做,如果有人访问“一些-子页面”(或任何其他子页面,并不重要),一个cookie应设置如下:
- cookie的名称:启动
- cookie的值:0421
- Cookie有效:在启动,所以在这种情况下,四月
这里的21是我到目前为止有:
<?php
if ($_GET['launch'] != "null") {
date_default_timezone_set('Europe/Berlin');
$launchdate = $_GET['launch'];
$launchdatenew->format('*********'); // Here I probably need to convert the "0421" to a readable time, but I dont know how
// or probably using this version?
$launchdatenew = date_format(date_create_from_format('m d', $launchdate), '*********'); // Here I probably need to convert the "0421" to a readable time, but I dont know how
setcookie("Launch", $launchdate, $launchdatenew, "/"); // The Cookie-Name should be "Launch", the value "0421", and it should expire when the launch starts
} ?>
你能帮我整理一下吗?我不知道如何将“0421”转换为可以设置为cookie过期日期的新格式。不幸的是我的PHP技能几乎为零。
非常感谢! 再见, 伊姆雷
您是否收到错误?什么不行?显而易见,这里跳出来的是你的信任用户的土地数据'$ _GET ['launch'];'然后将其存储在用户的土地上。 – ficuscr
不,我没有测试它,因为我确定它不会工作(我不知道如何将“0421”转换为可设置为cookie的过期日期的新格式。 它不是问题,用户可以操纵它 - 他们不会。 – Imre
他们会。永远不要相信他们。 – ficuscr