0

I have saved my session in database, Now I want to get the shopping cart session of special user by user_id after scanning a qrcode and set that shopping cart session for Auth::user().

as you know, the session table in databse have these fields: id, user_id, ip_address, user_agent, payload, last_activity

how to access the $cart = session()->get('cart'); by user_id ?

aref razavi
  • 413
  • 2
  • 12
  • Do you use any cart packages? Something like, `$user = User::findOrFail($user_id); $cart = $user->get('cart');` should work. – iamab.in Aug 06 '22 at 08:29

1 Answers1

0

You should change the session_driver in config\session.php from the file to a database like:

'driver' => env('SESSION_DRIVER', 'database'),

and created the sessions table

php artisan session:table

and also change your .env file SESSION_DRIVER=database

After that DB session will work and you can check in our DB and you can manage it accordingly.

Rajeev Singh
  • 1,724
  • 1
  • 6
  • 23