Session_start() requires me to re-input password
<p>I have a basic form that sends data to a form that processes the data then redirects the user to a third page that displays the data that the user submitted in the form:</p>

<ol>
<li>Form.php - User inputs data</li>
<li>Action.php - User's inputted data is stored in MySQL; session_start() used to send variables to Confirm.php</li>
<li>Confirm.php - Prints out the user data using session_start()</li>
</ol>

<p>The directory containing all three files is password protected via Cpanel. Normally, a dialog box pops up requesting my username/pw when I first visit form.php, and then I don't need to input again, unless I close my browser. But now, after implementing session_start(), I have to re-input my username/pw when the form is submitted. How do I prevent this? Is the session_start() somehow destroying a cookie? Adding session_start() to form.php does not fix the problem.</p>

<p>Thanks for any help.</p>

<p>Form:</p>

<pre><code>    &lt;form name="fc" method="Post" action="action.php" onSubmit="return validate();"&gt;
        &lt;input type="text" name="researcher" value="" size="30"&gt;&lt;br&gt;
        &lt;input type="text" name="subid" value="" size="30"&gt;&lt;br&gt;
        &lt;select name="gender"&gt;&lt;option value="Gender" selected&gt;Select Gender&lt;/option&gt;
            &lt;option value="0"&gt;Male&lt;/option&gt;
            &lt;option value="1"&gt;Female&lt;/option&gt;
        &lt;/select&gt;&lt;br&gt;
        &lt;select name="race"&gt;&lt;option value="Please select race..." selected&gt;Select Race&lt;/option&gt;
            &lt;option value="0"&gt;White&lt;/option&gt;
            &lt;option value="1"&gt;Non-White&lt;/option&gt;
            &lt;option value="2"&gt;Indian American&lt;/option&gt;
        &lt;/select&gt;
        &lt;input type="submit" name="submit" value="Submit Form"&gt;
</code></pre>

<p>Action:</p>

<pre><code>&lt;?php 
if(isset($_POST['submit']))
{

    // Save variables
    session_start();
    $_SESSION['id'] = $row[0];
    $_SESSION['researcher'] = $row[1];
    $_SESSION['s_id'] = $row[2];
    $_SESSION['s_gender'] = $row[3];
    $_SESSION['s_race'] = $row[4];
    $_SESSION['s_group'] = $row[5];
    $_SESSION['s_date'] = $row[6];
    $_SESSION['submit'] = $_POST['submit'];

    // MySQL operations (not shown)

    // Redirect to the confirm page
    header('Location: confirm.php');
    exit();
}
else
{
    // Redirect to the main page
    header('Location: form.php');
    exit();
}

?&gt; 
</code></pre>

<p>Confirm</p>

<pre><code>&lt;?php 

// Start session
session_start();

// If the session id variable is set
if(isset($_SESSION['id']))
{

    echo "&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;";

    // Print out form data
    echo "&lt;p&gt;You inputted the following:
    &lt;tr&gt;&lt;td width=\"35%\"&gt;Researcher&lt;/td&gt;&lt;td&gt;".$_SESSION['researcher']."&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td width=\"35%\"&gt;Subject's ID&lt;/td&gt;&lt;td&gt;".$_SESSION['s_id']."&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td width=\"35%\"&gt;Subject's Gender&lt;/td&gt;&lt;td&gt;".$gender_code[$_SESSION['s_gender']]."&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td width=\"35%\"&gt;Subject's Race&lt;/td&gt;&lt;td&gt;".$race_code[$_SESSION['s_race']]."&lt;/td&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td width=\"35%\"&gt;Date&lt;/td&gt;&lt;td&gt;".$_SESSION['s_date']."&lt;/td&gt;&lt;/tr&gt;";
    echo "&lt;/body&gt;&lt;/html&gt;";

    // Delete Session
    $_SESSION = array();
    if (isset($_COOKIES[session_name()])) { 
        $params = session_get_cookie_params();
        setcookie(session_name(), '', 1, $params['path'], $params['domain'], $params['secure'], isset($params['httponly']));
    }
    session_destroy();
}
else {
    // Redirect back to form
    header('Location: form.php');
    exit();
}
?&gt; 
</code></pre>
