• Good day,

    I am having trouble adding a session to wp_get_referer().

    Here is my current code:

    <?php
    
    // use the WordPress tag wp_get_referer to assign the referring URL to the variable $referer
    $referer = wp_get_referer();
    $_Session
    
    // check if the URL is a specific one
    if ( $referer == "https://site1.com" ) {
    
      echo '<span class="referrer-display"> <a href="itmsitedev.com/scol">RETURN TO YOGA FOR SCOLIOSIS</a> </span></p>';
    
    } else {
    
      echo "";
    
    }
    ?>

    It is currently working but when the user transfer to another page or refresh the page the text disappear. I want it to store it in a session. Can someone point me to the right direction thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter NR Dev

    (@anown2)

    Note: This is the correct code

    <?php
    
    // use the WordPress tag wp_get_referer to assign the referring URL to the variable $referer
    $referer = wp_get_referer();
    
    // check if the URL is a specific one
    if ( $referer == "https://site1.com" ) {
    
      echo '<span class="referrer-display"> <a href="itmsitedev.com/scol">RETURN TO YOGA FOR SCOLIOSIS</a> </span></p>';
    
    } else {
    
      echo "";
    
    }
    ?>

    $_Session

    is not included.

    Moderator bcworkz

    (@bcworkz)

    Any time a request will result in the use of session variables, you must call session_stat() before any content is output. It’s sort of like how you must declare a global before any time you wish to use it.

    More on using sessions is here:
    https://php.net/manual/en/session.examples.basic.php
    Follow the links on the right after the jump for even more.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add session to wp_get_referer()’ is closed to new replies.