Home >php教程 >PHP源码 >PHP 通过 Cookie 记录用户的访问时间

PHP 通过 Cookie 记录用户的访问时间

PHP中文网
PHP中文网Original
2016-05-25 17:16:011392browse

php代码:

<?php
 setcookie( "vegetable", "artichoke", time()+3600, "/",".oschina.net", 0 );
 ?>
 <html>
 <head>
 <title>Setting and Printing a Cookie Value</title>
 </head>
 <body>
 <?php
 if ( isset( $_COOKIE[&#39;vegetable&#39;] ) ) {
     print "<p>Hello again, your chosen vegetable is ";
     print "{$_COOKIE[&#39;vegetable&#39;]}</p>";
 } else {
     print "<p>Hello you. This may be your first visit</p>";
 }
 ?>
 </body>
 </html>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn