Note that there are some explanatory texts on larger screens.

plurals
  1. POsession_start and $_SERVER variable in Wordpress
    primarykey
    data
    text
    <p>I have a client which has wish that url referer gets send along contact email. This already worked and suddenly stopped over night, with no clues what's the problem.</p> <p>The platform is, sadly, Wordpress.</p> <p>This in the header.php:</p> <pre><code>if(!session_id()){ //session_destroy(); session_start(); } if(!isset($_SESSION['referer'])){ if(isset($_SERVER['HTTP_REFERER'])&amp;&amp;!empty($_SERVER['HTTP_REFERER'])){ $ref=strtolower($_SERVER['HTTP_REFERER']); if(strpos($ref,'facebook')!==false){$_SESSION['referer']="Facebook";$_SESSION['refererURL']=$ref;} elseif(strpos($ref,'google')!==false){$_SESSION['referer']="Google";$_SESSION['refererURL']=$ref;} else{$_SESSION['referer']="Web";$_SESSION['refererURL']=$ref;} } } </code></pre> <p>and this is in my contact-us.php:</p> <pre><code>$referer=trim($_SESSION['referer']); $refererURL=trim($_SESSION['refererURL']); </code></pre> <p>According to the code, I should be getting three different referers depending on where user has come from, but I'm constantly getting "Web" aka. no referer specified.</p> <p>What am I doing wrong?</p> <p>And to clarify:</p> <ul> <li><code>session_start()</code> hasn't been run before header.php,</li> <li><code>add_action( 'init', 'session_start' );</code> doesn't work,</li> <li>no errors produced, it just saves the wrong referer,</li> <li>this exact code has worked 1 day ago, now it doesn't and as far as I know, no changes has been made!</li> </ul> <p><strong>EDIT:</strong> I have moved everything to <code>$_COOKIE</code> variables and removed entry from xmlrpc.php <code>$_COOKIE = array();</code> and it's working. It appears that wordpress has some strange logic when it comes to <code>$_SESSION</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload