Unregistering variables and deleting sessions

To get rid of a persistent variable, call $sess->unregister() with the name of that variable. The value of the formerly registered variable is still available after the call to unregister, but the variable is no longer persistent and will be lost at the end of the current page.

To get rid of all session related data including the session record in the database, the current session id and the session cookie in the users browser, call $sess->delete(). In shopping applications this is commonly done when the user commits his order to get rid of the current shopping cart and everything else. You may want to remember selected information about that user, though, as shown below.

        <?php
          page_open(array("sess" => "Shop_Session"));

          // send order as mail
          mail_order($shopowner, $user, $cart);

          // delete the current session
          $sess->delete();

          // now get a new session id, but retain the users
          // address and name:
          page_open(array("sess" => "Shop_Session")); // will force auto_init again!
          $sess->register("user");  // could be done in auto_init as well

        ?>