Cookies for Smart Search in E-commerce

2

I want to do, for example, on Saraiva's website:

link

When doing a search (eg "Hitchhiker's Guide to the Galaxy") the url is directed to a smart search url:

link

They are totally different but identical sites, and they import the information of Name, Cart, Products in the Cart, State and any information relevant to purchase from one site to another.

My question is how do they do this, I've been researching and seen about cookies, but I'm having some difficulties understanding the concept and applying some practical example to see how it would be, is there any way to help me to better understand how it works? Or how do I set up a cookie with the data I need to transfer?

    
asked by anonymous 19.02.2014 / 12:38

2 answers

2

Cookies would not be necessary. You can mount the url with parameters via javascript, in the event onLoad of the other page you would check the value of the parameter and perform the search using it.

Suppose you have <input type=text id=busca> , and a button to search <input type=button id=btnBuscar> use the following code:

$('#busca').onkeyup(function(){
  var ValorDigitado = $(this).val();
  var URLBusca      = "http://busca.livrariasaraiva.com.br/";
  var ParametrosURL = "search#w="+ValorDigitado+"&PAC_ID=&af=";
  $('#btnBuscar').click(function(){
    document.location.href = URLBusca+ParametrosURL;
  });
});

So as a result clicking will lead you to:

  

>

In that case, you would change this URL to your search address, and within this search page it would have to be .php ai you could redeem the value of the w parameter:

$StringBusca = $_GET['w'];

With the search string would be easy, then just run the search in your database and return to the user.

    
19.02.2014 / 13:02
1

The fact that websites have different formats does not prevent them from using the same database.

When you send the user from one site to another, you simply place a single ID in the URL or even in a cookie. Note that the user's cart ID will suffice, so you do not need anything else to link the two sessions, if the base with the customer's items and data is accessible by both addresses.

    
19.02.2014 / 18:58