Re: using sessions instead of cookie

From: Date: Sat, 21 Jan 2006 15:55:01 +0000
Subject: Re: using sessions instead of cookie
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-229011@lists.php.net to get a copy of this message
http://php.net/manual/en/ref.session.php Ross wrote:
I have never used sessions before. How do I change the follow from COOKIES to SESSIONS in php (I do not know how to set a session)... At present the script uses an iframe with cookies but I believe if I use sessions I can leave out the iframe. http://www.ecurry.net/menu.phps http://www.ecurry.net/order2.phps The scipt adds a name and count to the cookie array, then works out the total using the order2 script. if (isset($add)){ ${$food} = intval($_COOKIE['cookie'][$food]); ob_clean(); $new= $$food+1; include('names.php'); setcookie("cookie[$food]", "$new $name"); } ; if (isset($minus)){ ${$food} = intval($_COOKIE['cookie'][$food]); if (${$food} == 0) { } else {; ob_clean(); $new= $$food-1; include('names.php'); setcookie("cookie[$food]", "$new $name"); } } and the order2 script... if (isset($_COOKIE['cookie'])) { foreach ($_COOKIE['cookie'] as $name => $quantity) {
     if ($name == "pakora") {$sub_total = $sub_total + ($priceA * $quantity);  $pricecode= $priceA; check_zero($quantity, $pricecode);}
  if ($name == "haggis_fritter") {$sub_total = $sub_total + ($priceB * $quantity); $pricecode= $priceB;check_zero($quantity, $pricecode);}
}}
-- --------------------------------------------------------- http://www.ciwcertified.com - Master CIW Designer http://www.zend.com - Zend Certified Engineer http://www.jamesbenson.co.uk ---------------------------------------------------------

« previous php.general (#229011) next »