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.
Reply to discussion (solution)
Set Cookie,setcookie (' name ', ' value ', Time () +24*3600);
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);
}
$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);
The user opens the page for the first time, records the cookie value, and accesses the corresponding page by the cookie's next visit.
The time to set the cookie is ready. Expire on expiration
Use cookies to meet your needs, but users may see different pages if they clear their cookies or change their browsers.
It is recommended that the IP of the visitor be combined with the timestamp of the day 0 to find the remainder of 3 to determine
If the requirement is 24 hours from the time of the visit, 2 methods will be used together