How to Restore Guest Basket After User Login in Aimeos

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
unknow76616
Posts: 48
Joined: 30 Apr 2023, 12:46

How to Restore Guest Basket After User Login in Aimeos

Post by unknow76616 » 04 Jul 2024, 09:43

Hi everyone,

I am currently working on an Aimeos Laravel and I'm facing an issue with handling user baskets. Specifically, I want to restore the basket of a guest user after they log in to their account.

Here's the scenario:

* A guest user adds items to their basket.
* The user then decides to log in.
* After logging in, I want the items from their guest basket to be merged with their existing user basket (if they have one), or simply use the guest basket if they don’t have an existing basket.

i want something like this

Code: Select all

$gust_basket_id = $session->get('aimeos/basket/list');
            if (Auth::attempt($credentials, true)) {
                $request->session()->put('aimeos/basket/list', $gust_basket_id);
                .....
but this not working ... :?

unknow76616
Posts: 48
Joined: 30 Apr 2023, 12:46

Re: How to Restore Guest Basket After User Login in Aimeos

Post by unknow76616 » 04 Jul 2024, 10:10

I commented this line

Code: Select all

// $request->session()->invalidate();
Now the basket works as expected.
I hope this does not break anything else?

User avatar
aimeos
Administrator
Posts: 8631
Joined: 01 Jan 1970, 00:00

Re: How to Restore Guest Basket After User Login in Aimeos

Post by aimeos » 08 Jul 2024, 08:58

Where did you remove that line? It may cause a security issue but not sure.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

unknow76616
Posts: 48
Joined: 30 Apr 2023, 12:46

Re: How to Restore Guest Basket After User Login in Aimeos

Post by unknow76616 » 08 Jul 2024, 09:22

Thanks , I confirmed that it doesn't have any negative impact.
AuthenticatedSessionController.php > create(Request $request)

Code: Select all

public function create(Request $request): View{
             .....

            // $request->session()->invalidate();

            $request->session()->regenerateToken();

            return view('auth.shop-login', ['logo' => $logo]);
}

Post Reply