Jump to content
kalle@makewebo

Logout from two shops with same domain

Recommended Posts

Hi!

 

So we have two shops that are on the same domain. www.domain.com (Shop 1) and www.domain.com/shop (Shop 2). What we want is that when you logout from shop 2 that you also are logged out from shop 1 and vice versa. We got login to work, but logout seems impossible. It works fine on our local environment with both login and logout. Since everything is on the same domain I just can't understand why the cookies won't be cleared. So we have a module that is hooked to hookActionAuthentication (login) and hookActionCustomerLogoutAfter (logout) and one Configuration value holding the shop id of the opposite shop. This is our code:

public function hookActionAuthentication($params) {

        $cookie = new Cookie('ps-s' . Configuration::get('OPPOSITE_SHOP'));
        $shop = new Shop(Configuration::get('OPPOSITE_SHOP'));
        $cookie->__set('id_compare', $this->context->cookie->id_compare);
        $cookie->__set('id_customer', $this->context->cookie->id_customer);
        $cookie->__set('customer_lastname', $this->context->cookie->customer_lastname);
        $cookie->__set('customer_firstname', $this->context->cookie->customer_firstname);
        $cookie->__set('logged', 1);
        $cookie->__set('is_guest', $this->context->cookie->is_quest);
        $cookie->__set('passwd', $this->context->cookie->passwd);
        $cookie->__set('email', $this->context->cookie->email);
        $cookie->setPath($shop->getUrls()[0]['physical_uri']);
        $cookie->write();
    }

    public function hookActionCustomerLogoutAfter($params) {
         $cookie = new Cookie('ps-s' . Configuration::get('OPPOSITE_SHOP'));
          $shop = new Shop(Configuration::get('OPPOSITE_SHOP'));

          setcookie($cookie->getName(), '', 1);
          setcookie($cookie->getName(), '', 1, '/');
          setcookie($cookie->getName(), '', 1, $shop->getUrls()[0]['physical_uri']);
    } 

So what am I missing? I just can't understand why the cookies won't be cleared. The physical_uri for both shops is '/' (needed to unset it for local development). Even tried other php scripts for clearing cookies, which clears them locally but doesn't logout on opposite shop. So what kind of [spam-filter] does Prestashop do with my cookies?

 

Kind Regards

Kalle

Edited by kalle@makewebo (see edit history)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More