Cookies for intelligent search in E-commerce

Asked

Viewed 243 times

2

I want to do as for example on the Saraiva site:

http://www.livrariasaraiva.com.br/

When doing a search (e.g., "Galaxy Backpacker’s Guide") the url is directed to a smart search url:

http://busca.livrariasaraiva.com.br/search#w=guide%20do%20do% backpacker%20das%20galaxias&PAC_ID=&af=

They are totally different but unique websites, and they import the information from Name, Cart, Products in Cart, Status and any relevant information to purchase from one site to another.

My question is how do they do this, I’ve been researching and seeing 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 understand better how it works? Or how I set some cookie with the data I need for transfer?

  • Actually you don’t need to use cookies, you really want to use them?

  • search on how to store data in session... search by localStorage and sessionStorage, probably this will give you some basis.

  • 1

    Paulo, not necessarily. I would like to know how to do, what I discovered were cookies so far...

  • On the example you gave, there’s nothing "smart", it’s just a subdomain, the logged-in user’s session is passed like any other page (with some adjustments). And the search data is passed through GET.

  • What probably occurs is that the same application is responsible for the two subdomains (www and search). User and cart information may be stored in section variables, and the section cookie on the user’s machine must be valid for any subdomain. But what exactly are you trying to do? Use two subdomains, or share information between two totally different sites?

  • 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 only need to place a single ID in the URL or even a cookie. Note that the ID of the user’s cart would suffice, not needing anything else to link the two sessions, if the database with the client’s items and data is accessible by the two addresses.

Show 1 more comment

1 answer

2

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

Suppose you have one <input type=text id=busca>, and a search button <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;
  });
});

Then as a result of clicking you would be redirected to:

http://busca.booksbookshops.com.br/search#w=Guide%20do%20Mochileiro%20das%20Galaxias&PAC_ID=&af=

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

$StringBusca = $_GET['w'];

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.