can't destroy session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
the_NEWBIE_ON_THE_BLOCK
Forum Newbie
Posts: 1
Joined: Sat Feb 28, 2004 6:20 am

can't destroy session

Post by the_NEWBIE_ON_THE_BLOCK »

i cant destroy the session that i have created it come up with the following errors
Notice: Undefined variable: _SESSION in C:\Program Files\Apache Group\Apache2\htdocs\cafe2\13\Circle2\final.php on line 9

Notice: Undefined variable: _SESSION in C:\Program Files\Apache Group\Apache2\htdocs\cafe2\13\Circle2\final.php on line 11

Notice: Undefined variable: _SESSION in C:\Program Files\Apache Group\Apache2\htdocs\cafe2\13\Circle2\final.php on line 11

Warning: session_destroy(): Trying to destroy uninitialized session in C:\Program Files\Apache Group\Apache2\htdocs\cafe2\13\Circle2\final.php on line 15


the script is below

<?php


$approved = 'Y'; // Practice

require_once ('../mysql_connect.php'); // Connect to the database.

// Turn the cart into a database-safe version.
$c = addslashes (serialize($_SESSION['cart']));

$query = "INSERT INTO orders (customer_id, total, order_date, approved, cart) VALUES ({$_SESSION['cid']}, {$_SESSION['total']}, NOW(), '$approved', '$c' )";
$result = mysql_query ($query);

$_SESSION = array(); // Destroy the variables.
session_destroy(); // Destroy the session itself.
if ($approved == 'Y') {
// Send an email.
echo '<p>Thank you for your order!</p>';
} else {
echo '<p>Your order could not be placed!</p>';
}

mysql_close();

?>
tsg
Forum Contributor
Posts: 142
Joined: Sun Jan 12, 2003 9:22 pm
Location: SE, Alabama
Contact:

Post by tsg »

You must have

Code: Select all

<?
session_start();
?>
At the top of everypage. That might be the problem
Post Reply