When a guest user puts items into a cart, they are stored in a session
session('cart', 'item1')
However once user has logged in, this session gets destroyed for some reason and I can no longer access it. Why does this session is removed and how do I keep it after user log in?
In your login function you could copy the cart from the session to a local variable and then after Auth::login($user), put the cart from the variable back into the session.
@bashy when I access the same method via get , it reads well, when I switch back to post the session item is removed. It seems that post request somehow removes this session item.
@bashy it does stay when I tried it on another (not login) route, both GET/POST requests. But when I tried to post to postRegister method which is in the same controller, then the session erases just like in case of the postLogin.