session - PHP session_destroy() stopped working -


session_destroy() stopped working due unknown reasons , active session not getting destroyed. have tried solutions mentioned on se not working. below code using.

session_start(); # note session start $_session = array();  session_unset(); session_destroy(); header('location: thankyou'); exit(); 

entire script:

<?php     //session_start();      $to = 'equote@domain.com';       $products = $_post['product_id'];     $subject = "request quote";     $errors = array();     $i = 0;     if(!isset($_post['name']) || $_post['name'] == ''){         $errors[$i] = 'please enter name';         $i++;     }      if(!isset($_post['company_name']) || $_post['company_name'] == ''){         $errors[$i] = 'please enter company name';         $i++;     }       if(!isset($_post['phone']) || $_post['phone'] == ''){         $errors[$i] = 'please enter phone number';         $i++;     }      if(!isset($_post['email']) || $_post['email'] == ''){         $errors[$i] = 'please enter email';         $i++;     }     /*if($_post['email2'] != $_post['email'] ){         $errors[$i] = 'your email not match';         $i++;     }*/        if($i > 0){         $msg = serialize($errors);         $info = serialize ($_post);         header('location: /checkout/cart/?msg='.$msg.'&info='.$info);         exit;     }     $name = mysql_escape_string($_post['name']);     $company_name = mysql_escape_string($_post['company_name']);     $address = $_post['address'];     $city = $_post['city'];     $state = $_post['state'];     $zip = $_post['zip'];     $country = $_post['country'];     $phone = $_post['phone'];     $fax = $_post['fax'];     $email = $_post['email'];     $contact_by = $_post['contact_by'];     $sales_person = $_post['sales_person'];     $items = '';     foreach($products $product){         $items .= $product . ',';     }      //connect db!!     mysql_connect('localhost','machiner_dbusr','d2ev3k98zx76ygz');     mysql_select_db('machiner_db');     $date = date('m-d-y');     $sql = "insert `quote` (`name`, `company_name`, `address`, `city`, `state`, `zip`, `country`, `phone`, `fax`, `email`, `contact_by`, `item_skus`, `date`) values ('$name', '$company_name', '$address', '$city', '$state', '$zip', '$country', '$phone', '$fax', '$email', '$contact_by', '$items', '$date')";     mysql_query($sql);     $name = $_post['name'];     $company_name = $_post['company_name'];     $i = 0;     foreach($products $product){         $entity_id = 0;         $product = str_replace(' ','',$product);         $sql = "select `entity_id` `catalog_product_entity` `sku` ='$product'";         $result = mysql_query($sql);         if($row = mysql_fetch_assoc($result)){             $entity_id = $row['entity_id'];         }         if($entity_id != 0){             $sql = "select `value` `catalog_product_entity_text` `entity_id` ='$entity_id' , `attribute_id` ='58'";             $result = mysql_query($sql);             if($row = mysql_fetch_assoc($result)){                 $product_name[$i] = $row['value'];             }              $sql = "select `value` `catalog_product_entity_varchar` `entity_id` ='$entity_id' , `attribute_id` ='446'";             $result = mysql_query($sql);             if($row = mysql_fetch_assoc($result)){                 $location[$i] = $row['value'];             }          } else{             $product_name[$i] = '';         }         $i++;     }       $message = '';      $message .= 'company name: '.$_post['company_name']. "\n";     //$message .= 'address: '.$_post['address']. "\n";     //$message .= 'city: '.$_post['city']. "\n";     //$message .= 'state: '.$_post['state']. "\n";     //$message .= 'zip code: '.$_post['zip']. "\n";     $message .= 'country: '.$_post['country']. "\n";     $message .= 'name of person: '.$_post['name'] . "\n";     $message .= 'phone: '.$_post['phone']. "\n";     /*$message .= 'fax: '.$_post['fax']. "\n";*/     $message .= 'email: '.$_post['email']. "\n\r";     $message .= 'comments: '.$_post['comments']. "\n\r";     $message .= 'inventory items:'. "\n";     //$message .= '<table cellpadding="5" width="100%">'. "\n\r";     //$message .= '<thead>'. "\n\r";     //$message .= '</thead>'. "\n\r";     //$message .= '<tbody>'. "\n\r";     $i = 0;     foreach($products $product){         $message .= 'stock number:   '. $product. "\n";         $message .= 'description:   '. $product_name[$i]. "\n";         $message .= 'location:      '. $location[$i] . "\n\r";         //$message .= '<tr><td>'.$product.'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>'.$product_name[$i].'</td><td>'.$location[$i].'</td>'.'</tr>'. "\n\r";         $i++;     }     //$message .= '</tbody>'. "\n\r";     //$message .= '</table>'. "<br />\n\r";      // send html mail, content-type header must set //$headers  = 'mime-version: 1.0' . "\r\n"; //$headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; // additional headers     $headers = 'from: '.$_post['name'].' <'.$_post['email'].'>' . "\r\n";     mail($to, $subject, $message, $headers);  session_start(); # note session start $_session = array();  session_unset(); session_destroy(); header('location: thankyou'); exit(); ?> 

i clear $_session, , works me.

<?     session_start();     $_session = array();     header("location: index.php"); ?> 

then must user $_session in script.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -