Jump to content

jon1009

New Members
  • Posts

    5
  • Joined

  • Last visited

jon1009's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Scrap that Ive just looked into isset() and realised that its would only return true/false. So I went with the following that ok to use? <?php if(isset($_SESSION["cruise_id"])) { if($_SESSION["cruise_id"] != $page->id) { $_SESSION = ""; session_destroy() ; } } ?>
  2. Iam using the follow but cant seem to get it to work. If i remove the isset() it works but throws a error once the session has be destroyed. <?php if(isset($_SESSION["cruise_id"]) == $page->id) { }else{ $_SESSION = ""; session_destroy() ; }?>
  3. Hello All, Iam creating a shopping cart and basing the session content iam adding a add / remove to the product. First question is that a good away of doing it? Second would be Iam throwing a error if the $_session doesn't exist for both the session and the 'array_key_exists' Would best way to solve this be by wrapping it iin a if if($_SESSION["cart_products"]) {the code below} else {out put add button} $out = " <div class='row'> <form method='post' action='http://localhost/cart/'> <div class='medium-4 columns'> {$room->title} {$room->id} </div> <div class='medium-4 columns'> £{$room_cost_pp} p/p x {$room->room_spaces} guests = £{$room_cost} </div> <div class='medium-2 columns'> <input type='hidden' name='cabin_id' value='{$room->id}' /> <input type='hidden' name='cabin_name' value='{$room->title}'/> <input type='hidden' name='cabin_cost' value='{$room_cost}'/> <input type='hidden' name='return_url' value='{$current_url}' />"; $search_array = $_SESSION["cart_products"]; if (array_key_exists($room->id, $search_array)) { $out.="<input type='hidden' name='remove_code[]'' value='{$room->id}' /> <button type='submit' class='alert button'>Remove Cabin</button>"; }else { $out.="<input type='hidden' name='type' value='add' /> <button type='submit' class='success button'>Add Cabin</button>"; } Cheers Jon
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.