Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 13, 2021 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e4149e47f7981ecf7222512e27cd9d8e to your computer and use it in GitHub Desktop.
Save parzibyte/e4149e47f7981ecf7222512e27cd9d8e to your computer and use it in GitHub Desktop.
<?php
function agregarProductoAlCarrito($idProducto)
{
// Ligar el id del producto con el usuario a través de la sesión
$bd = obtenerConexion();
iniciarSesionSiNoEstaIniciada();
$idSesion = session_id();
$sentencia = $bd->prepare("INSERT INTO carrito_usuarios(id_sesion, id_producto) VALUES (?, ?)");
return $sentencia->execute([$idSesion, $idProducto]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment