Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session not being destroyed

Status
Not open for further replies.

mancroft

Programmer
Joined
Oct 26, 2002
Messages
267
Location
GB
I have started a session in a shopping cart as below:

THIS IS IN db.php FILE

Code:
<?php
$dbServer = &quot;localhost&quot;;
#$dbUser = &quot;aff_ffsc&quot;;
$dbUser = &quot;k&quot;;
$dbPass = &quot;xxxxx&quot;;
$dbName = &quot;aff_art&quot;;

function ConnectToDb($server, $user, $pass, $database){

$s = @mysql_connect($server, $user, $pass);
$d = @mysql_select_db($database, $s);

if(!$s || !$d) return false; else return true;}

function GetCartId(){ if(isset($_COOKIE[&quot;cartId&quot;])) {
return $_COOKIE[&quot;cartId&quot;];} else
{
session_start();
setcookie(&quot;cartId&quot;, session_id(), time() + ((3600 * 24) * 30), &quot;/&quot;, &quot;.hosting.com&quot;,1);return session_id();}}
?>


I am trying to destroy the session using the code below:

THIS IS IN THE ThankYou.php FILE RIGHT AT THE END

Code:
session_unset();
session_destroy();
MySQL_close();


And the following message gets generated:

Code:
Warning: session_destroy(): Trying to destroy uninitialized session in ThankYou.php on line 297


Does the value of the session have to be passed from db.php to ThankYou.php?

If so, how? Or is there another mistake?


Thanks.
 
u have to use session_start() before u destroy the session.
Its in db.php in your case, so u have to include that in your thankyou.php file.


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top