欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2022-06-17 14:22:28
...
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['vegetable'] ) ) {
     print "<p>Hello again, your chosen vegetable is ";
     print "{$_COOKIE['vegetable']}</p>";
 } else {
     print "<p>Hello you. This may be your first visit</p>";
 }
 ?>
 </body>
 </html>