S
S
Stalker_darkway2015-12-17 10:32:02
PHP
Stalker_darkway, 2015-12-17 10:32:02

How to add an array to a session?

Hello. Tell me where to go next?
There is a form

<form id="formCart" class="formCart" action="javascript:void(null);">
        <input class="id" type="hidden" name="hitId" value="1" />
        <input class="name" type="hidden" name="hitName" value="<?=$element['NAME'];?>" />
        <input class="price" type="hidden" name="hitPrice" value="<?=$element['PRICE'];?>" />
        <input class="basket" type="submit" name="hitAdd" value="В корзину" />
</form>

Here is the AJAX form
$('.formCart').submit(function(){
var cartForm = $(this).serialize();
$.ajax({
type: 'POST',
url: ' rostail.ru/cart.php ',
data: cartForm,
success: function(response){
console.log(response)
$('.orderName').html(response)
}
});
});

In cart.php, this is the code:
<?php
session_start();

$_SESSION = $_POST;

exit();
?> It is
necessary that the list of goods be supplemented, not replaced and remain there until the purchase.
I tried a bunch of options, but I can’t do anything so that they are recorded when you click into the session. Prompt a direction where to me to dig. I started studying AJAX and sessions in depth only a week ago, but I still can’t gnaw through (((.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AntohaRomaha, 2015-12-17
@AntohaRomaha

Xs .. you store an array of purchased goods in cookies .. you parse a line of cookies .. IMHO in this direction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question