Problem with PHP sessions in WordPress with constant defaults

I am having a weird problem that occurs when changing the default permalinks in WordPress.

When I put this code in my functions.php file in my theme (or even in the root index.php file in WordPress) and move between them and refresh several pages (for example, the / about page), my counter often runs twice.

This issue is reproducible on every server I tried, and on any WordPress theme or installation. Another thing that confuses my brain even more is that it is not found in Safari, Internet Explorer (6, 7, and 8), but only in Firefox . I am using Firefox 3.6.8 and have tried it on both Mac OS X and Windows XP.

session_start();

$counter = $_SESSION['wp_action_counter'];

if( !isset($counter) ){
$counter = 0;
}

$counter++;

echo $counter;

$_SESSION['wp_action_counter'] = $counter;

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

, , .

0
4

, .

<?php wp_head(); ?> , WordPress :

<link rel='next' title='About' href='http://mysite.dev/about/' />

prefetched, , . wp_head(); .

0

, , firebug net, , , , , ( prefetched, php- ..).

0

... , script, css ( - ) , ? , IE 404, FF . , ...

0

Here you can find information on how to control the output in your header: http://wpquicktips.wordpress.com/2010/08/30/keep-a-track-of-what-happens-in-your-header-and -footer /

0
source

Source: https://habr.com/ru/post/1761429/


All Articles