In general, I’m running data through ajax to a php page, and there I record them in a session after reloading the page and there’s nothing on the bitrix in the output session array. Here is the code to send data:

$('.btn-price').click(function() { $.ajax({ url: 'addtobasket.php', type: "POST", dataType: "JSON", data: { 'id': <?=$arResult["ID"]?>, 'name': '<?=$arResult["NAME"]?>', 'img': '<?=$arResult["DETAIL_PICTURE"]["SRC"]?>', 'qty': $('input[name="qty"]').val(), 'price': $('input[name="price"]').val() }, success: function (data) { if(data.status == "OK") { alert("Товар добавлен."); window.location.reload(); } }, error: function(xhr, status, error) { alert(xhr.responseText + '|\n' + status + '|\n' +error); } }); }); 

Here is the code of the work in the file:

 if(isset($_SESSION['card'][$_REQUEST["id"]])){ //если в массиве уже есть добавляемый товар $_SESSION['card'][$_REQUEST["id"]]['qty'] += $_REQUEST["qty"]; //total_quantity(); echo json_encode(['status' => 'OK']); } else { //если в корзине нет такого товара $_SESSION['card'][$_REQUEST["id"]]['name'] = $_REQUEST["name"]; if ($_REQUEST["img"] != "") { $_SESSION['card'][$_REQUEST["id"]]['img'] = $_REQUEST["img"]; } $_SESSION['card'][$_REQUEST["id"]]['qty'] = $_REQUEST["qty"]; $_SESSION['card'][$_REQUEST["id"]]['price'] = $_REQUEST["price"]; //total_quantity(); echo json_encode(['status' => 'OK']); } 

I have already broken my head what the problem is, tell me maybe it’s not at all in the code.

  • Where is the beginning of the session yours? - teran September
  • @teran is the same bitrix the beginning of the session somewhere in his prologues - Moonwolf45
  • most importantly these prologues zakludit. in the error log, that is what? request id is present? - teran
  • @teran doesn’t have any inclusions, as soon as I plugged it in, it worked - Moonwolf45
  • 99% of the questions with "nothing is written to the session" are connected with the fact that the start of the session is not called (explicitly or not explicitly). the remaining one percent will be due to the fact that the server cannot write session files to disk for reasons of lack of rights or space. - teran

0