How to write to create a Cookie on the client side?

Good day help with the code.
wanted to duplicate the basket like him
but to me a tabular output(although I think it's not really that important)
the address of the page where they should be /catalog
written in blade

 @foreach ($catalogs as $catalog)

@endforeach

 <table class="table table-bordered table-striped table-condensed flip-content">
<thead>
the <tr>

<th>Category</th>
<th>Vin</th>
<th>Analog</th>
<th>Name</th>
<th>Price</th>
<th>Quantity</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody><tr>
 <td>{!! $catalog->category->name !!}</td>
 <td><span class="vin">{!! $catalog->vin !!}</span></td>
 <td>{!! $catalog->analog_vin !!}</td>
 <td><span class="title">{!! $catalog->title !!}</span></td>
 <td><span class="price">{!! $catalog->price !!}</span></td>
 <td>{!! $catalog->number !!}</td>
 <td>{!! $catalog->status !!}</td>
<td>
 <a href="#" class="btn btn-primary buy-btn" id="{{$catalog->id}}" role="button">Buy</a>
</td>
</tr></tbody>

 </table>


the plug-in js
$('.buy-btn').click(function()
{
 catalog_id=parseInt($(this).attr('id')); //get item id
 price=parseInt($(this).parent().prev().children().html()); //get the price of the goods and convert the value to a number parseInt
 vin=$(this).parent().prev().children().html(); //get the number
 title=$(this).parent().parent().children().html(); //item name
//now we need to find out whether the cookie is already such a product
 order=$.cookie('basket'); //get the cookie name basket
 !order ? order= [] order=JSON.parse(order);
if(order.length==0)
{
 order.push({'catalog_id': catalog_id, 'price':price, 'amount':1, 'vin':vin, 'title':title},{ expires: 7, path: '/catalog' });//add object to empty array
}
else
{
 flag=false; //flag that indicates that such goods are not in the basket
 for(var i=0; i<order.length; i++) iterate through the array in search of the product availability information from the shopping cart { if(order[i].catalog_id="=catalog_id)" order[i].amount="order[i].amount+1;" if the product already the shopping cart, add +1 to the number (amount) flag="true;" raise a flag that there is and with him is to do nothing } if(!flag) flag is omitted, then not add it. order.push({'catalog_id': catalog_id, 'price':price,'amount':1,'vin':vin,'title':title}); an existing array a new object $.cookie('basket',json.stringify(order)); alter string objects persistent cookies count_order(); run the function to display the number of orders, the text function will write below. });< code></order.length;>
br><br> but cook Basket is not created at all.<br> how to rewrite the script, probably line <br><pre><code>catalog_id=parseInt($(this).attr('id')); //get item id price=parseInt($(this).parent().prev().children().html()); //get the price of the goods and convert the value to a number parseInt vin=$(this).parent().prev().children().html(); //get the number title=$(this).parent().parent().children().html(); //item name</code></pre>
July 9th 19 at 13:38

Find more questions by tags HTTP Cookies