Heim  >  Artikel  >  php教程  >  PHP 通过 Cookie 记录用户的访问时间

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

PHP中文网
PHP中文网Original
2016-05-25 17:16:011320Durchsuche

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>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn