When logging in using cookies, when landing the page, in the browser to write a cookie, indicating that you have logged in, with the permission to login, by default, this cookie is valid during the browser opening, when the browser reopened, need to login again, of course, You can also set the lifecycle of a cookie to allow the cookie to function after a few seconds, so that it can be destroyed during browser opening or destroyed during shutdown, mainly to see if the time is reached, and the cookie is stored in the browser. By default, only the sibling and sibling directories of the cookie and the pages of the directory can be accessed, of course, can be set in that directory can be accessed, set the cookie with the Setcookie () function, receive cookies with super Global array $_cookie to obtain
Setcookie (cookie name, cookie value, life cycle unit seconds, which directory can be accessed, domain name suffix);
Get that cookie with $_cookie[' cookie name '];
Easy to print history with cookies
<?php$uri=$_server[' Request_uri '];if (!isset ($_cookie[' history ')) {$his []= $uri;} else{$his =explode (' | ', $_cookie[' history '); Echo ' Jdaso '; Print_r ($his); Array_unshift ($his, $uri); $his =array_ Unique ($his);//Remove Duplicate if (count ($his) >10) {Array_pop ($his);}} Setcookie (' History ', implode (' | ', $his)),//print_r (Implode (' | ', $his));//print_r ($_cookie); $id =isset ($_get[' id ']) ? $_get[' id ']:0;//print_r ($his);? ><p><a href= "cookie.php?id=<?php echo $id-1?>" > Prev </a></p><p><a href= " cookie.php?id=<?php echo $id +1?> "> Next </a></p><ul><li> Browsing History </li><?php foreach ($his as $v) {><li><?php echo $v;? ></li><?php }?></ul>
Use of cookies