1
I’m making a cart using session
, has how to increase the time of session
?
below is the class I created for my shopping cart.
class carrinhocompra{
public function __construct(){
if(!isset($_SESSION['carrinho'])){
$_SESSION['carrinho'] = array();
}
}
public function adicionar($id, $qtd=1, $form_id=NULL){
if(is_null($form_id)){
$indice = sprintf("%s:%s", (int)$id, 0);
} else {
$indice = sprintf("%s:%s", (int)$id, (int)$form_id);
}
if(!isset($_SESSION['carrinho'][$indice])){
$_SESSION['carrinho'][$indice] = (int)$qtd;
}
}
public function aterarQtd($indice, $qtd){
if(isset($_SESSION['carrinho'][$indice])){
if($qtd > 0){
$_SESSION['carrinho'][$indice] = (int)$qtd;
}
}
}
public function excluirProd($indice){
unset($_SESSION['carrinho'][$indice]);
}
}
If the answer helped you or solved your problem, take a vote and mark it as the correct answer, otherwise give more details about what you tried and the results. Always vote and choose the right answers is good practice and helps other users.
– user3603