Difference between revisions of "How to use shopping cart buttons on domains other than domain where aMember is installed"

From aMember Pro Documentation
Jump to: navigation, search
 
Line 16: Line 16:
 
         header("Access-Control-Allow-Origin: $origin");
 
         header("Access-Control-Allow-Origin: $origin");
 
         header("Access-Control-Allow-Credentials: true");
 
         header("Access-Control-Allow-Credentials: true");
 +
        header("Access-Control-Allow-Headers: origin, x-requested-with, cookie");
 
     }
 
     }
 
}
 
}
 
</source>
 
</source>

Latest revision as of 06:33, 29 August 2018

Add this code to site.php file:


/**
 * list of domains where you want to use shopping cart buttons
 * one domain per line
 */
$list = <<<CUT
example.com
www.example.com
CUT;

if (isset($_SERVER['HTTP_ORIGIN'])) {
    $origin = $_SERVER['HTTP_ORIGIN'];
    $host = parse_url($origin, PHP_URL_HOST);
    if (in_array($host, explode("\n", $list))) {
        header("Access-Control-Allow-Origin: $origin");
        header("Access-Control-Allow-Credentials: true");
        header("Access-Control-Allow-Headers: origin, x-requested-with, cookie");
    }
}