You're insetting the variables within the chout() function only This has no
effect on
the local copies as they are not in scope here. You have successfully
destroyed the
session so when you refresh they are unset.

What I do with sessions is keep them all within a session array so you can
then destroy
the session locally by unsetting that array. If I have a function that I
want to change session
variables at all I make it take the session in as a parameter and pass it
back as the return value.


        Tim Ward

> -----Original Message-----
> From: Phillip Perry [SMTP:[EMAIL PROTECTED]]
> Sent: 13 June 2002 19:45
> To:   Tim Ward; Martin Towell; Tom Rogers; Php
> Subject:      RE: [PHP] beginner in PHP
> 
> Yes, here is the checkout code I used...
> 
> function chout(){
>               session_destroy();
>               unset ($mycart);
>               unset ($cart_items);
>               echo "<p>Thank you for shopping!</p>";
>                               }
> 
> Any suggestions?
> 
> -----Original Message-----
> From: Tim Ward [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 13, 2002 4:18 AM
> To: Martin Towell; Tom Rogers; Php; Phillip Perry
> Subject: RE: [PHP] beginner in PHP
> 
> 
> From the symptoms it sounds like you're destroying the session okay but
> leaving the variables
> In the script. Are you sure you're unsetting them at the appropriate scope
> level. 
> 
> Tim Ward
> www.chessish.com <http://www.chessish.com> 
> 
>       ----------
>       From:  Phillip Perry [SMTP:[EMAIL PROTECTED]]
>       Sent:  13 June 2002 05:18
>       To:  Martin Towell; Tom Rogers; Php
>       Subject:  RE: [PHP] beginner in PHP
> 
>       Thanks Martin!! That really helped out a lot. And thanks to all who
> tried to
>       help me. I appreciate it!
> 
>       I have one other question that is really not so much important as it
> is
>       annoying, but I can't figure it out myself.
> 
>       I'm practicing with sessions. What I'm making..if you couldn't tell
> by the
>       array output from before...is a test shopping cart. Now the
> annoyance is
>       that when I click the checkout link it's just supposed to destroy
> the
>       session and reset everything to 0 including the shopping cart. And
> also if
>       an item is clicked, that item gets deleted. With both choices when I
> click
>       once the session does get destroyed, but everything stays on the
> page until
>       I refresh the page. I want the info to get reset when I click the
> link.
>       Here's the delete and checkout code...remember they both do actually
> work,
>       just not as I want. Any suggestions on how to make it refresh on a
> click
>       only?
> 
>       / DELETE SHOPPING CART ITEMS
> 
>       function chout(){
>                       session_destroy();
>                       $mycart = array();
>                       $cart_items = 0;
>                       echo "<p>Thank you for shopping!</p>";
>                                       }
> 
>       if ($action == delnow)
>       {
>       unset($mycart[$itemid]);
>       }
> 
>       // END DELETE SHOPPING CART ITEMS
> 
>       if ($action == checkout)
>       {
>       chout();
>       }
> 
>       -----Original Message-----
>       From: Martin Towell [mailto:[EMAIL PROTECTED]]
>       Sent: Wednesday, June 12, 2002 11:55 PM
>       To: '[EMAIL PROTECTED]'; Tom Rogers; Php
>       Subject: RE: [PHP] beginner in PHP
> 
> 
>       here's the revised loop....
> 
> 
>       $cat_cnt = count($catalog);
>       while (list($key,$value) = each($mycart))
>       {
>         for ($j = 0; $j < $cat_cnt; $j++)
>           if ($value == $catalog[$j]["itemcd"])
>           {
>             echo $catalog[$j]["unitprice"];
>             break;
>           }
>       }
> 
> 
>       -----Original Message-----
>       From: Martin Towell [mailto:[EMAIL PROTECTED]]
>       Sent: Thursday, June 13, 2002 1:50 PM
>       To: '[EMAIL PROTECTED]'; Tom Rogers; Php
>       Subject: RE: [PHP] beginner in PHP
> 
> 
>       Ah! $catalog is a 2D array - any your if statement is expecting a 1D
>       array...
> 
>       -----Original Message-----
>       From: Phillip Perry [mailto:[EMAIL PROTECTED]]
>       Sent: Thursday, June 13, 2002 1:52 PM
>       To: Tom Rogers; Php
>       Subject: RE: [PHP] beginner in PHP
> 
> 
>       I meant Martin :) sorry.
> 
>       -----Original Message-----
>       From: Phillip Perry [mailto:[EMAIL PROTECTED]]
>       Sent: Wednesday, June 12, 2002 11:44 PM
>       To: Tom Rogers; Php
>       Subject: RE: [PHP] beginner in PHP
> 
> 
>       Array ( [0] => gerainiums [1] => roses [2] => roses [3] => roses [4]
> =>
>       roses [5] => roses )
> 
>       1
>       1
> 
>       Your output is different from the last print_r that Tom had me do. I
> wonder
>       why that is
> 
>       -----Original Message-----
>       From: Tom Rogers [mailto:[EMAIL PROTECTED]]
>       Sent: Wednesday, June 12, 2002 11:44 PM
>       To: [EMAIL PROTECTED]; Php
>       Subject: RE: [PHP] beginner in PHP
> 
> 
>       Hi
>       Then I guess you will have to add some debug code
>       try this before the while loop and make sure your if ($value ==
>       $catalog["itemcd"]) will produce a match (and you do need the quotes
> really
>       :)
> 
>       echo "<pre>".print_r($catalogue)."<br>".print_r($mycart)."</pre>";
>       Tom
> 
>       At 11:31 PM 12/06/2002 -0400, Phillip Perry wrote:
>       >Thanks, but that didn't work either
>       >
>       >-----Original Message-----
>       >From: Tom Rogers [mailto:[EMAIL PROTECTED]]
>       >Sent: Wednesday, June 12, 2002 11:32 PM
>       >To: [EMAIL PROTECTED]; Php
>       >Subject: Re: [PHP] beginner in PHP
>       >
>       >
>       >Hi
>       >itemcd and unitprice should be in quotes I think if they are keys
> in an
>       >array.
>       >$catalog["itemcd"]
>       >$catalog["unitprice"]
>       >
>       >Tom
>       >
>       >At 10:56 PM 12/06/2002 -0400, Phillip Perry wrote:
>       > >Can someone tell me why this doesn't work?
>       > >The $mycart array is fine and the $catalog array is also fine but
> nothing
>       > >inside the if statement prints. I've tried other echo statements
> but
>       >nothing
>       > >prints at all.
>       > >
>       > >while (list($key,$value) = each($mycart))
>       > >         {
>       > >         if ($value == $catalog[itemcd])
>       > >                 {
>       > >
>       > >                         echo $catalog[unitprice];
>       > >
>       > >                 }
>       > >         }
>       > >
>       > >
>       > >Thanks
>       > >
>       > >Phil
>       > >
>       > >
>       > >--
>       > >PHP General Mailing List (http://www.php.net/)
>       > >To unsubscribe, visit: http://www.php.net/unsub.php
>       >
>       >
>       >--
>       >PHP General Mailing List (http://www.php.net/)
>       >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
>       --
>       PHP General Mailing List (http://www.php.net/)
>       To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
>       --
>       PHP General Mailing List (http://www.php.net/)
>       To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
>       --
>       PHP General Mailing List (http://www.php.net/)
>       To unsubscribe, visit: http://www.php.net/unsub.php
> 
>       --
>       PHP General Mailing List (http://www.php.net/)
>       To unsubscribe, visit: http://www.php.net/unsub.php
>       

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to