Jump to content

session_destroy doesnt work cnt update data properly to the database + PHP


menukadevinda

Recommended Posts

HI,

according to my knowledge session_destroy() function would destroy all session variables and mysql_close() would close connection with the database.

  i make a simply logoff.php file and close myssql connection and destroy session. but i still get values from the database and session variables. and doesnt work properly

 

here is the code

<?php
session_start();
/* 
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once '../database/db_connecting.php';
$dbname="sahansevena";//set database name
$con=  setConnections();//make connections use implemented methode in db_connectiong.php
mysql_select_db($dbname, $con);
//update the time and date of the admin table
$update_time="update admin set last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname'limit 3,4";
//my admin table contain 5 colums they are id, username,password, last_logged_date, last_log_time
$link= mysql_query($update_time);
// mysql_select_db($dbname, $link);
//$con=mysql_connect('localhost', 'root','ijts');

       $result="select * from admin where username='a'";

        $result=mysql_query($result);
mysql_close($con);
//here i just check after closing data baseconnection whether i do get reselts but i do, why?
echo "after the cnnection was closed";
  echo "<html>";
echo "<table border='1' cellspacing='1' cellpadding='2' align='center'>";
      echo "<thead>";
           echo"<tr>";
                   echo "<th>";
                   echo ID;
                   echo"</th>";
                   echo" <th>";echo Username; echo"</th>";
                    echo"<th>";echo Password; echo"</th>";
                    echo"<th>";echo Last_logged_date; echo "</th>";
                   echo "<th>";echo Last_logged_time;  echo "</th>";
               echo" </tr>";
           echo" </thead>";
           echo" <tbody>";
while($row= mysql_fetch_array($result,MYSQL_BOTH)){
             echo "<tr>";
              echo "<td>";
              echo $row[0];
               echo "</td>";
                   echo "<td>";
              echo $row[1];
              echo "</td>";
                  echo "<td>";
              echo $row[2];
               echo "</td>";
                   echo "<td>";
                echo $row[3];
              echo "</td>";
                  echo "<td>";
              echo $row[4];
               echo "</td>";
            echo "</tr>";
     }
         echo" </tbody>";
         echo "</table>";
         echo "</html>";
     session_destroy();
session_commit();

echo "session and database are closed but i still get values".$_SESSION['admin'];
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.