How to Restore Guest Basket After User Login in Aimeos
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!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 48
- Joined: 30 Apr 2023, 12:46
How to Restore Guest Basket After User Login in Aimeos
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
but this not working ... 
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);
.....

-
- Posts: 48
- Joined: 30 Apr 2023, 12:46
Re: How to Restore Guest Basket After User Login in Aimeos
I commented this line
Now the basket works as expected.
I hope this does not break anything else?
Code: Select all
// $request->session()->invalidate();
I hope this does not break anything else?
Re: How to Restore Guest Basket After User Login in Aimeos
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,
give us a star
If you like Aimeos,

-
- Posts: 48
- Joined: 30 Apr 2023, 12:46
Re: How to Restore Guest Basket After User Login in Aimeos
Thanks , I confirmed that it doesn't have any negative impact.
AuthenticatedSessionController.php > create(Request $request)
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]);
}