0

My wordpress php script is incremented by two instead one. ++$_SESSION['visitor'] is incremented by two !

In functions.php

if ( !isset( $_SESSION['visitor'] ) ) $_SESSION['visitor'] = 1; else ++$_SESSION['visitor'];

I have to do this in echo to have Session + 1 otherwise I get Session + 2: In any php file

`<?php echo  --$_SESSION['visitor'] ; ?>`

I don't know what can cause this.

If I increment when I echo The session is well incremented by 1 , why ?.

if ( !isset( $_SESSION['visitor'] ) )  $_SESSION['visitor'] = 1; else $_SESSION['visitor'];
<?=  $_SESSION['visitor'] .' + ' . ++$_SESSION['visitor']; ?>

The increment add well +1 only on any php file inside theme but add +2 every time using it in functions.php. For both I use the same syntax ++$_SESSION['visitor']

I have add params to session to allow subdomains in functions.php:

session_set_cookie_params(0, '/', '.website.com');

imagIne
  • 49
  • 1
  • 6

0 Answers0