May 3, 2020 05:00 AM
(This post was last modified: May 3, 2020 05:32 AM by Aussie.)
Duly note, I am using session_start(); preceding any code in both these php files:
Problem in a minimum reduced format:
index.php
Inside index.php, posting to add_to_cart.php using AJAX.
add_to_cart.php:
The output of the alert is null
Problem in a minimum reduced format:
index.php
PHP Code
<?php
session_start();
$_SESSION['msg'] = 'hello';
?>Inside index.php, posting to add_to_cart.php using AJAX.
PHP Code
<?php
$.ajax({
type:"POST",
url:"add_to_cart.php",
async: false, //tested with this true and now false
data:{test_product:productName},
success:function(response){
alert(response);
}
});
add_to_cart.php:
PHP Code
<?php
session_start();
echo json_encode($_SESSION['msg']);
?>

