Home » Jquery » php – Session is empty for ajax call on live server but working on localhost

php – Session is empty for ajax call on live server but working on localhost

Posted by: admin February 22, 2020 Leave a comment


Today i’m facing the unnessesary error in my code. I had tried the codes are working fine at localhost(XAMPP) but when i had uploaded it to live server there was i’m getting error

My codes : –


<table class="table" id="myParoCart"></table>

Ajax (updateMyCart.php) :

        include "inc/config.php";
        $sl = 1;
        foreach($_SESSION["shopping_cart"] as $keys => $values){ 
            $query=mysqli_query($me, "SELECT * FROM `pro_item` WHERE `id`='".$values['item_id']."'");

        if ($totalPrice>299) {

        if ($shippingCharge=='0') {
            $shippingCharge='Free Shipping';
echo    '   <tbody>
                    <th>Sub Total : </th>
                    <td><span class="price">₹'.$totalPrice.'</span></td>
                    <th> Shipping Charge:</th>
                    <td><span class="price">'.$shippingCharge.'</span></td>
                    <th> Discount:</th>
                    <td><span class="price">-₹'.$discount.'</span></td>
                    <th class="cart_btn_cntnt"> Grand Total :</th>
                    <td><span class="cart_btn_cntnt_clr">₹'.$grandTotal.'</span> </td>

            echo "Empty Cart";

Script (jQuery) :

function updateParoCart(){
    $('#myParoCart').load('updateMyCart.php',function () {
updateParoCart(); // This will run on page load
    updateParoCart() // this will run after every 5 seconds
}, 100);

When i had run this code at my localhost (XAMPP) there are i’m not facing any error but after uploading it to my server i’m getting error that is i’m getting empty $_SESSION['shopping_cart'] WHERE i had used $_SESSION['shopping_cart'] on my HTML file and that working fine at both place (Live & Local).

I had Search on Internet also here and i had found some solution like settings for php.ini files but can’t understand how to apply that.

How to&Answer: