Make sure storage folder has correct permissions.
Feb 25, 2021
4
Level 12
Session works on local machine but having trouble in production
Both Server and Production are on Laravel 6, PHP 7.3, Session Driver: file
I store item in a cart using session: ProductController:
public function axiosAddQuantity(Request $request)
{
$input = $request->all();
$product = Product::find($input['item']['id']);
//$oldCart = session()->has('cart') ? session()->get('cart') : null;
$oldCart = null;
if(session()->has('cart'))
{
$oldCart = session()->get('cart');
}
$cart = new Cart($oldCart);
$quantity = $input['item']['quantity'];
$cart->addQuanitity($product, $product->id, $quantity);
$request->session()->put('cart', $cart);
return redirect()->back();
}
The above method works only on local machine, but it does not work on the server. The data is submitted using axios, I have tried it without axios and got the same problem on the server. The sessions file are created on the server but no idead why it can't pick up the right session file.
Session works on the server if I store and get it in the same method.
Level 12
Solved, Not a server issue, it was my JavaScript.
Please or to participate in this conversation.