[resolved] Not Firefox compatible? (2 posts)

  1. mindspins
    Posted 5 years ago #

    I use the following code in my header.php to keep track of the posts visited by users, but somehow Firefox stores two ID's on one page visit. The second ID is from the next page published. The last post published is the only page that gets me one ID, since there is no next post.

    It seems Firefox is loading the header.php twice? Is this a WordPress bug? Do you know what could be wrong?! I really appreciate all the help I can get.

    global $wp_query;
    $post_id = $wp_query->post->ID;
    $cookietime = time()+3600*24*365;
    $lt = '|';
    if (isset($_COOKIE['tst'])) {
    	$viewedstring = $_COOKIE['tst'];
    	$viewedstring .= $post_id.$lt;
    	setcookie('tst', $viewedstring, $cookietime, '/', '.domain.com');
    	$viewedstring = $post_id.$lt;
    	setcookie('tst', $viewedstring, $cookietime, '/', '.domain.com');
  2. mindspins
    Posted 5 years ago #

    Solution here!

Topic Closed

This topic has been closed to new replies.

About this Topic