Session frustration

Once I login to my site, I set three session variables, the I go to another page where I have

<?php
foreach ($_SESSION as $key=>$val)
echo $key. ": ".$val. "<br>";
?>

which seem to work 9its output is at the top-left of screenshot

Problem is in the textbox on the right whose value is 1 produces,

<input type='text' value='1' name='u_id'>

but the php used to produce that is

    echo "<input type='text' value='{$_SESSION['id']}' name='u_id'>";

why is the value 1 and not 3?

noticed something weird, when I echo the session variables right away, they seem right, but if I echo them later (after the submit button, t he id goes back to 1 (screenshot)


Why is it doing this?

guess I was getting a conflict somewhere, changed the variables name to u_id and now it works

Hard to tell without seeing the rest of the code, something must be setting $_SESSION[‘id’] value back to 1 before you display the form.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.