Q: super stumped on simple session variables i have the following two snippets of code working fine..
    <?php session_start();
$query = '23';
$_SESSION['testing'] = $query;
echo $_SESSION['testing'] . "<html><br></html>";

echo "<html><a href='http://www.nhl-statistics.com/scripts/test2.php'>click</a></html>"
?>

and this links too..
<?php session_start();

echo $_SESSION['testing'] . "<html><br></html>";
echo "<html><a href='http://www.nhl-statistics.com/scripts/test2.php'>click</a></html>"
session_destroy();
?>

however.. i will post two pages in which the same methods do not work and am hoping you guys can tell me why
<?php session_start();  

?>


<script type="text/javascript">
function destroyit()
{
<?php session_destroy(); ?>
}
</script>



</head>
<body>
    <div id="page" align="center">
        <div id="header">
            <div id="companyname" align="left"></div>
            <div align="right" class="links_menu" id="menu"><a href="/index2.php">Home</a> | <a href="logged.php">Log In</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a> </div>
        </div>
        <br />
        <div id="content">
          <div id="leftpanel">
                <div class="table_top">
                    <div align="center"><span class="title_panel">News</span> </div>
                </div>
        <div class="table_content">
                    <div class="table_text">
                        <p class="news_date">blah.com<br />
                          blah.<br />
                        </p>
            </div>
          </div>
                <div class="table_bottom">
                    <img src="images/table_bottom.jpg" width="204" height="23" border="0" alt="" /><br />
                </div>
                <div class="table_top"></div>
                <div class="table_content">
                    <div class="table_text">


<html><form action="?" method="post">
 Username: <input type="text" name="uname" /><br />
 Password: <input type="text" name="pword" /><br />
 <input type="submit" />
 </form> </html>



</div>
                </div>
                <div class="table_bottom">
                    <img src="images/table_bottom.jpg" width="204" height="23" border="0" alt="" />
                </div>
                 <div class="footer">

                <p><br />
                  <a href="#">Home</a> | <a href="#">About Us</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a> | blah.com</a>.
          </p>
            </div>
          </div>
          <div id='contenttext' class='contenttext'>
            <?php $username="a75sdadmin";
$password="1dBasdns2";
$database="a75asdesting";
$pword = $_REQUEST['pword'];
$uname = $_REQUEST['uname'];
mysql_connect('myssd.com',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = mysql_query("SELECT * FROM `username` WHERE `password` = '$pword' AND `username` = '$uname'");
$exsists = 0;

        WHILE($rows = mysql_fetch_array($query)){
         $exsists = 1;
         break;
         }
            if ($exsists){
            $_SESSION['usern23']=$uname;
            $_SESSION['logged']=1;
            header('Location: logged2.php');


                    }



mysql_close();

 ?>
        </div>
</body>
</html>

the session variables won't post to this page for some reason.. (logged2)
<?php session_start();
echo 'welcome, ' . $_SESSION['usern23'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

    <meta name="author" content="Wink Hosting (www.winkhosting.com)" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" href="style.css" type="text/css" />
    <title>Aqua</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/classarray.js"></script>

<script type="text/javascript">
function doit()
{
var x=document.getElementById("multi2");
var xindex = x.selectedIndex;
var y=document.getElementById("multi3");
var yindex = y.selectedIndex;

var class4 = x.options[xindex].text;
var class5 = y.options[yindex].text;

var link = "index3.php?rav=" + class4 + "&pun=" + class5
window.open(link, '_self');
}
</script>

<script type="text/javascript">
function destroyit()
{
<?php session_destroy(); ?>
}
</script>

<script type="text/javascript">

$(document).ready(function(){
  $("button.yo1").click(function rock(){
    $("div.class1").html("<h1>&nbsp;</h1><h1><br /><select id='multi2' style='width:100px;'></select><br /></h1><button id='yo8' class='yo8'>Pick Class</button>")
    childless();
    $("button.yo8").click(function rock2(){
    $("div.class3").html("<h1>&nbsp;</h1><h1><br /><select id='multi3'><option>random teacher</option></select><br /></h1><button id='yo9' class='yo9'>Pick Teacher</button>")
  $("button.yo9").click(function rock3(){
  $("div.golow").html("<button onClick='doit();'>click for notes</button>")
  $("button.yo10").click(function rock3(){
  $("div.contenttext").html("<div id='yi'></div>")
  });
  });
  });
  });
});

</script>

</head>
<body>
    <div id="page" align="center">
        <div id="header">
            <div id="companyname" align="left"></div>
            <div align="right" class="links_menu" id="menu"><a href="index2.php">Home</a> | <a href="/logged.php">Log In</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a> </div>
        </div>
        <br />
        <div id="content">
          <div id="leftpanel">
                <div class="table_top">
                    <div align="center"><span class="title_panel">News</span> </div>
                </div>
        <div class="table_content">
                    <div class="table_text">
                        <p class="news_date">sdfgass.com<br />
                          dsf<br />
                        </p>
            </div>
          </div>
                <div class="table_bottom">
                    <img src="images/table_bottom.jpg" width="204" height="23" border="0" alt="" /><br />
                </div>
                <div class="table_top"></div>
                <div class="table_content">
                    <div class="table_text">
                      <?php 
                     error_reporting(E_ALL);
                     echo $usern . '<html><br></html>';
                     echo '<html><a href="logged.php" onclick="destroyit();" >logout</a></html>';
?>

</div>
                </div>
                <div class="table_bottom">
                    <img src="images/table_bottom.jpg" width="204" height="23" border="0" alt="" />
                </div>
                 <div class="footer">

                <p><br />
                  <a href="#">Home</a> | <a href="#">About Us</a> | <a href="#">Products</a> | <a href="#">Our Services</a> | <a href="#">Contact Us</a> | Sasd.com</a>.
          </p>
            </div>
          </div>
          <div id='contenttext' class='contenttext'>

 you are now logged in 
        </div>
</body>
</html>


A: <script type="text/javascript">
function destroyit()
{
<?php session_destroy(); ?>
}
</script>

This will NEVER work. PHP is executed immediately on the server, long before the browser ever gets it hands on the generated page. If you look at the page's source, you'll see the above code has generated:
<script type="text/javascript">
function destroyit()
{

}
</script>

Basically you're starting a session, then IMMEDIATELY destroying it. If you want to destroy a session from the client-side javascript, you'll have to make an AJAX call (or submit a form, click on a link, etc...) to call a PHP script which does the destruction.
