How do you write this code about cookies?
The problem is this:
For example, there are 3 pages of qq.html, baidu.html, so.html, and then randomly open one of them from the rand.php.
How to add a cookie control, within the set time range (such as 24 hours), the same user each time only open the same page, For example, the user opens the baidu.html at random for the first time, so the next time they visit, they will still only open baidu.html, not qq.html and so.html.
------to solve the idea----------------------
if (isset ($_cookie[' url ')) {
Header (' Location: '. $_cookie[' url ')];
}else{
$URLARR = Array (' qq.html ', ' baidu.html ', ' so.html ');
$urlId = Array_rand ($URLARR, 1);
Header (' Location: '. $URLARR [$urlId]);
Setcookie (' url ', $url, Time () +24*3600);
}
------to solve the idea----------------------
$arr = Array (' qq.html ', ' baidu.html ', ' so.html ');
$page = ";
if (Isset ($_cookie[' page ')) {
$page = $_cookie[' page '];
}else{
$page = $arr [Mt_rand (0,2)];
Setcookie (' page ', $page, Time () +86400);
}
echo file_get_content ($page);