Jump to content

Need help using the same cookies across multiple presta shops


Recommended Posts

Hi there, first off big thank you for the shop system, its really nice and a breath of fresh air after e-commerce!

Basically what I am trying to do, is set up a few different shops selling different items, but that run from the same product database while also using different configurations (this I have managed)!

What I now need is when you go to click checkout you are sent to a dedicated checkout shop on a seperate URL (still using the same DB), that will be able to recognise your cart from the previous shop and then proceed with the checkout there.

I've figured that the cart is related to the cookies, and need a way of making the each of the shops generate and recognise the same cookie. Is this possible?

I've been diving into the settings.inc.php, and using the same _cookie_key_ and _cookie_iv_, but Firefox shows up as the cookies being seperate, and the products arnt carried across to the checkout store.

I figure this may be down to the _PS_BASE_URI_, where i've changed that to "/" and been doing a find/replace to make _PS_BASE_URI_. become _PS_BASE_URI_.'/shopname'., but this has brought up all kinds of issues!

Am I completely off here? Is there an easier way to do this?

I'd really appreciate the help on this :)

Link to comment
Share on other sites

  • 11 months later...

Hi lafon,

It was nearly a year ago that I was having this issue. Eventually i learnt that due to security reasons, cookies cannot be shared between different web pages as this poses are really significant security risk. This isn't just regarding Presta, but for all websites/browsers.

The work around I had was to instead have multiple prestashops, by editing /config/settings.inc.php to point all the shops to the same database.

In the back end i then have a top level category for each shop, and have set each shop to only show categories from inside each category.

Hope that makes sense?
you can see it in action here:
http://www.massageforum.co.uk/shop/ and http://www.e4office.co.uk/

Both are running from the same presta backend which i access at http://www.bigwwshop.co.uk/ (under construction). So thats 3 shops on one database.

Hopefully this helps you, this took a while to get my head around last year!

Link to comment
Share on other sites

Thanks Mark for your quick response… but what I’m trying to do is to create a development environment in a separate server. I¡m having only one shop but I need to try new different changes, and don't want to affect the production service.

At this point and after reading a lot of threads, I guess that there is a cookie issue, which I really don’t know how to solve :S

If you have a clue about this, it will be appreciated!

Best!

Link to comment
Share on other sites

By new different changes are you referring to changes in the product data/database, or simply the design or the inbuilt functions?

One thing I did at once was create a local version of the live prestashop, but change the settings.inc.php to point to the live database (while setting the shop root for the local files so links/images would work).

What I ended up with was a local version of the store, but with all the live data as you would expect in the live shop. I could make changes to the CSS, functions and .tpl theme files without actually touching the live shop. This meant I could see how they would react with the live data also.

If you wanted it completely seperate however I would consider duplicating your shop onto a local developement server (using wamp/mamp/xxamp? i forget the names now!) and do an SQL export of all your live data and dump it into a local database.

It boils down really to if your changes are affecting the database or simply the php/css/js/tpl files.

Hope this helps!

Link to comment
Share on other sites

Goog suggestion Mark... but since the databases are located in different servers (both online, I'm not having a local environment), I can't access live database from the development environment for security reasons.

I'm doing CSS adjusments, as well as creating some new modules for future features. Also is a good practice to navigate throughout of the site to detect bugs, without interfering with the live shop statistics.

I have double checked the config.inc.php and the smarty.config.inc.php, and everything now is working well with the exception of the cart which is empty after the checkout button is pressed. No errors, not alert messages, just the cart empty.

The only difference I noticed is that the cookie is the same for both. Hence to that comes my confusion. Still trying to resolve :(

Link to comment
Share on other sites

Ahhh okay, I've just realised this was a problem I had before I reworked the checkout system. Originally I had a specific checkout website, that was purely for taking sales from the other shops before I realised I could have them all use the same database.

I havn't got the exact code with me as I'm at home now, though what I ended up doing for this problem if I remember rightly was have your shop send the data via post. If you're using the same data on both websites this could simply be the cart id number.

What I had was the checkout button link to a script on the other shop, which read the POST data (cart id), and recreated the session on the seperate checkout website. It all worked quite well.

This doesn't have to be the cart id, you could send the id's of the products and quantities if you'd like to create a completely new cart for the customer to run through the checkout with?

If this theory would help you out I could dig around for the little bits of script i wrote to do this, was pretty simplistic in the end... I remember it winding me up because it took me about 3-4 days to figure out... and 15 minutes to implement. Typical!

Link to comment
Share on other sites

Hi Mark!

Finally I found the solution with your suggestion... I made that script to call the other cart, and found that the script called by smarty weren't compiled correctly, so that what I did is to recompile the whole cart.

Now all is working, and what's best is that I have the same cookie ID in both ;)

Thanks a lot for your help!

Link to comment
Share on other sites

  • 3 weeks later...
Hi lafon,

In the back end i then have a top level category for each shop, and have set each shop to only show categories from inside each category.


Sorry to bring up such an old post.....
But I was wondering if somebody could explain how to do this step?

Thanks
Paul.
Link to comment
Share on other sites

×
×
  • Create New...