1. 程式人生 > >php+cookie實現獲取頁面訪問次數!

php+cookie實現獲取頁面訪問次數!

php+cookie實現獲取頁面訪問次數!

<?php
//訪問次數
            if($this->uid){
                if (!isset($_COOKIE[$this->uid.'visits'])) { $_COOKIE[$this->uid.'visits'] = 0; }
                $visits = $_COOKIE[$this->uid.'visits'] + 1;
                cookie($this->uid.'visits',$visits);
            }else{
                $visits =0;
            }
            $this->assign('visits',$visits);