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 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
<?php
 
 
/**
 
/**
 
  * list of domains where you want to use shopping cart buttons
 
  * list of domains where you want to use shopping cart buttons

Revision as of 08:04, 11 July 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");
    }
}