Hello!
Is it possible to configure session expiration and if it expires at all?
@salvisb
You can configure session expiration in your laravel projects, and yes sessions do expire. I may be wrong, but the default configuration has a timeout of about 2 hours I guess.
my cart won't save when redirect to other link
ex:
public function addtocart($id)
{
$product = products::find($id);
//$cate = $product->Pcate;
Cart::add(array('id'=>$id, 'name'=>$product->name, 'qty'=>1, 'price'=>$product->price, 'options'=>array('alias'=>$product->alias, 'img'=>$product->image, 'promo'=>$product->old_price)));
//print_r(Cart::content());
return redirect()->route('cart');
}
public function cart()
{
$cate = manufactures::all();
$content = Cart::content();
print_r(Cart::content());
//return view('shopcart', compact('cate','product'));
}
but I saw that 'content' value always null (IlluminateSupportCollection Object ( [items:protected] => Array ( ) )) . Could you help us to solve it?
same of MrLenh here!
Please give me more information on how to reproduce this error. Which Laravel version? Which session driver? Is it a new project or an existing project?
@Crinsane
Laravel 5.3.18
'driver' => env('SESSION_DRIVER', 'file'), --> this is what you mean?
It is a very new project!
Hello @Crinsane
I would like to remove a cart after 15min (expriation time) if the user has not paid the cart.
How can I do that with Laravel Session (without log out the user).
Thanks for your answer !
Can you help me @Crinsane ?
@bouffekai Help you with what?
Sorry, the previous question from @jaublanc-bobbies (I have two account) !
You'll have to keep track of the time yourself, and after 15 minutes call Cart::destroy() to empty the cart.
But if there are 20 running carts, I have to check 20 times every minutes if carts are not expired.. that might be heavy, isn't it ?
Or maybe there is a solution to run a timer in a session variable ?
Well that's really for you to implement. It's not something build into the cart. Might help to have a look at how Laravel has implemented the session lifetime. :)
Most helpful comment
@salvisb
You can configure session expiration in your laravel projects, and yes sessions do expire. I may be wrong, but the default configuration has a timeout of about 2 hours I guess.