I'm making a cart using session
, can you 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]);
}
}