Jump to content

php sessions array


Adaaam

Recommended Posts

Hello,

 

Well this is embarrasing. Can anyone tell me why the $_SESSION['values'] array keeps getting overwritten every time I try adding a new value to it? Instead of the new value being added to the end of the array, the whole array gets overwritten with the new value and I don't know why?

<?php
session_start();
$_SESSION['values'] = array();
if (isset($_POST['value'])) {
	$_SESSION['values'][] = $_POST['value'];
}
var_dump($_SESSION['values']) . '<br>';

?>
<html>
<head>
<title>Test</title>
</head>
<body>
<form method="post">
<input type="text" name="value">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Hope this makes sense, I really don't know why it's not working.

 

Thanks,

Adam

Link to comment
https://forums.phpfreaks.com/topic/297317-php-sessions-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.