PHP $ _SESSION ['key'] rewritten using the value of the enter button. What for?

Having the following problem in the PHP basket.

The dump of my session looks like this:

Array ( [username] => test@test.com [key] => 1 )

The cart has three buttons:

<form name='cartForm' action='cart.php' method='post'>
<input type='image' value='submit' name='continueshopping' src='x.jpg' />
<input type='image' value='submit' name='update' src='y.jpg' />
<input type='image' value='submit' name='checkout' src='z.jpg' />

every time I click one of the buttons, the page reloads and does what it needs (i.e. removes or adds an item) ... but the session array changes to the next one (depending on the button pressed)

Array ( [username] => test@test.com [key] => continueshopping_y )
Array ( [username] => test@test.com [key] => update_y )
Array ( [username] => test@test.com [key] => checkout_y )

Is [key] a reserved word? Why should the value of $ _SESSION ['key'] be overwritten from a form that just does a POST? This is a problem for our project, because we save the user account identifiers in [key], but this value is overwritten every time the button is placed in the basket.

, . , , , session_id(). , - . (PHP5), (PHP4).

.

+5
2

, ; , .

, register_globals , .

+1

continuehopping_y, update_y, checkout_y - INPUT x y, . , - :

foreach ($_POST as $key => $value) {
 .....
}

....
Many lines of code later ....
....

$_SESSION['key'] = $key;
// or,
session_register('key');
0

All Articles