PHP会话以防止viewcounter上的错误视图

I have a view counter on my blog which tracks how many times certain article has been viewed, however, this plugin that I use allows for endless hits simply by pressing F5.

I'm trying to edit the plugin so that it can only count one view per page visit.

I already created a cookie to prevent this from happening, which seems to work fine. Of course cookies could easily be disabled. This is why I tried to achieve the same thing using a PHP session.

Here is my code that, for some reason, doesn't seem to be working (the cookie works perfectly though):

session_start();
    if(($_COOKIE['last_ip_address_' . $id]!= $_SERVER['REMOTE_ADDR'] . '_' . $id) 
    || ($_SESSION['last_ip_address_' . $id]!= $_SERVER['REMOTE_ADDR'] . '_' . $id)) {
        if(!update_post_meta($id, 'views', ($post_views+1))) 
            add_post_meta($id, 'views', 1, true);
        }
        $_SESSION['last_ip_address_' . $id] = $_SERVER['REMOTE_ADDR'] . '_' . $id;  
        setcookie('last_ip_address_' . $id, $_SERVER['REMOTE_ADDR'] . '_' . $id, time()+3600);
        }
    }