I send ajax request data:
$.ajax({ url: '/engine/search.php', method: 'POST', data: { data:data }, xhrFields: { withCredentials: true }, success: function(){ console.log('Request sent successfully. Pending...') } }).fail(function(response){ console.log(response); }).done(function(data){ console.log('Validation passed, initiating redirect...'); window.location.href = 'https://search.' + document.location.hostname; }); To script:
<?php ini_set('session.cookie_domain', '.skytickets.ga'); session_set_cookie_params(0, '/', '.skytickets.ga'); session_start(); header('Access-Control-Allow-Credentials: true'); require('functions.php'); if(isAjax()) { $data = $_POST['data']; if(isset($data) && !empty($data)) { if(!preg_match('/[AZ][AZ][AZ]/', $data['from']) && !preg_match('/[AZ][AZ][AZ]/', $data['to'])) { header('HTTP/1.0 500 Internal Server Error'); die('Bad IATA codes provided'); } if(!validateDate($data['there']) && !validateDate($data['thence'])) { header('HTTP/1.0 500 Internal Server Error'); die('Bad date format provided'); } if(!preg_match('/^[1-9]*$/', $data['adults']) && !preg_match('/^[0-9]*$/', $data['teens']) && !preg_match('/^[0-9]*$/', $data['kids'])) { header('HTTP/1.0 500 Internal Server Error'); die('Bad passengers data provided'); } $_SESSION['search_data'] = json_encode($data); session_write_close(); } } else { header('HTTP/1.0 403 Forbidden'); die('Access denied'); } ?> After successful processing of the request in the .done() body, the client moves to the subdomain, in which the data should be output:
<?php session_start(); require('../engine/functions.php'); require('../engine/headers.php'); if(isset($_SESSION['search_data']) && !empty($_SESSION['search_data'])) var_dump($_SESSION['search_data']); unset($_SESSION['search_data']); ?> But instead of output, nothing happens, and if you remove the conditional operator, Notice: undefined index 'search_data' will be displayed, and var_dump () will output NULL. What I just did not try, still does not want to work.