Support the ongoing development of Laravel.io →
posted 9 years ago
Session
Last updated 1 year ago.
0

Shouldn't the login take place before use of the shopping cart?

0

No, the user add stuff to the cart and when they go to checkout they need to login or register

0

You should use route group for checkout

Route::group(array('prefix'=>'checkout','before'=>'auth'),function(){
})
0

The problem comes after Auth that the Session::getId(); is different than before Auth::login

I tried also with

$old_sid = Session::getId();

Auth::login(Auth::user());

Session::setId($old_sid);

Session::save();

But the session id is not set back and still does not work

Last updated 9 years ago.
0

I think you should set session name after call session name, not set id.

Because after login session id has been change

0

i only can second what tuyenlaptrinh is saying. i'm using a session Cart and a session User

0

The problem is that my cart is not stored in the session, but in a database table that have a session_id column

When i get the cart i do something like

Cart::where('session_id',Session::getId())->get();

After login the Session::getId() is different, so i will need to change my cart logic now to use cookies

0

boksiora, I'm doing it just like you are. Storing the cart data in a Cart.php model. At this point, I'm working to add guest checkout, but preserve the cart-in-database approach. My plan is to do just as you're doing and adding a "session_id" column to that table.

Did you change your cart logic to use sessions only? Or did you keep it in the database?

0

I used Session::getId() to get the session id and after that i used Session::setId($sessid); to set the session id and Session::start(); to load the data.

hope it helps.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

boksiora boksiora Joined 15 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.