Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function saveBasket(){
- global $basket;
- $basket = base64_encode(serialize($basket));
- setcookie('basket', $basket, 0x7FFFFFFF);
- }
- function basketInit(){
- global $basket, $count;
- if(!isset($_COOKIE['basket'])){
- $basket = ['orderid' => uniqid()];
- saveBasket();
- }else{
- $basket = unserialize(base64_decode($_COOKIE['basket']));
- $count = count($basket) - 1;
- }
- }
- function add2Basket($id){
- global $basket;
- $basket[$id] = 1;
- saveBasket();
- }
- $id = $_GET ["id"];
- if ($id){
- add2Basket ($id);
- header("Location: catalog.php");
- exit;
- }
- ?>
- <p>Товаров в <a href="basket.php">корзине</a>: <?=$count?></p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement