How should i design my session
<p>Currently, i am designing a website selling some products which would has a function to arithmetic calculation of the prices of items added to cart. The file is called cart.php and it has a function which display the session variable (total price) and this function could be used in other pages of my website.</p>

<p>The cart.php code is as follows:</p>

<pre><code>&lt;?php

session_start();
if (isset($addid))
{
    $quantity = mysql_query("SELECT id, quantity FROM product WHERE id=$addid");
    while ($quantity_row = mysql_fetch_assoc($quantity)){
        if  ($quantity_row['quantity']!=$_SESSION['cart_'.$addid]){
        $_SESSION['cart_'.$_GET['add']] +='1';
        }
    }
    header('Location: '.$page);
}
...
function cart(){
...
$_SESSION['totalamount'] = $total;
...
echo 'Total: $'.$total.'&lt;br/&gt;';
}
?&gt;
</code></pre>

<p>I would like to create a log in screen which allows members to log in (login.php) and the ability to logout(logout.php).</p>

<p>Therefore my question is this:</p>

<p>If the session is the same throughout the web application, then can i put the <code>session_start();</code> in login.php (this means starting a session right after user has been verified) and <code>session_destroy()</code> once user clicks logout(logout.php)? In this case, do i still need the session_start() inside cart.php?</p>
