<?
/*
#########################################
// new crome parameter
A cookie associated with a cross-site resource at http://iconify.design/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
*/
header('Set-Cookie: HttpOnly; SameSite=None;Secure');
#########################################



$hostname = $_SERVER['HTTP_HOST'];

// Use parse_url to break down the hostname into its component parts
$parsed_url = parse_url("http://" . $hostname);

// Extract the hostname from the parsed URL
$domain = $parsed_url['host'];

// Remove the subdomain from the hostname
$domain_parts = explode(".", $domain);


$domain_parts = array_reverse($domain_parts);
//test("domain_parts",$domain_parts);

$_XXXXX_host_domain = $domain_parts[1] . ".". $domain_parts[0];



//test("_XXXXX_host_domain",$_XXXXX_host_domain);




///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//// SET DIFFERENT COOKIE NAMES PER PORTAL 
//// to seek the sessions conflict-free

/// set default:
$_XXXXX_session_name = "TRANSCRIBER_member";

/*
/// over-write exceptions:
if(stristr($_SERVER['HTTP_HOST'],"admin.".$_XXXXX_host_domain))
{
	$_XXXXX_session_name = "TRANSCRIBER_admin";
}

if(stristr($_SERVER['HTTP_HOST'],"member.".$_XXXXX_host_domain))
{
	$_XXXXX_session_name = "TRANSCRIBER_member";
}
*/

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

ini_set('session.cookie_domain', $_XXXXX_host_domain);
session_name($_XXXXX_session_name);
session_start();

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////


if(empty($_SESSIONp['template']))
{
	$_SESSIONp['template'] = array();
}

if(empty($_SESSION['template']['company']))
{
	
	
	
	$tmp_sql = "SELECT *
				FROM templates_companies
				WHERE domain = '". $_XXXXX_host_domain ."'
				;";
	//test("tmp_sql",$tmp_sql);
	$templates_companies = readTHECASHIER($tmp_sql);
	//test("templates_companies",$templates_companies);

	//test("templates_companies",$templates_companies);



	if(!empty($templates_companies))
	{
		$templates_companies = object_to_array_v2($templates_companies);
		
		$_SESSION['template']['company'] = $templates_companies;
	}

}
//test("_SESSION['templates']['companies']",$_SESSION['template']['company']);

?>