In page1.php a user can enter a day name and it stores in session array called days.
<?
// starting the session
session_start();
if (isset($_POST['submit'])) {
$_SESSION['days'] = $_POST['days'];
}
?>
<strong>Add a day</strong>
<form action="" method"post">
<input type="text" name="days[]"/>
<input type="submit" name="submit" value="Submit!" />
</form>
<p><a href="/test/page2.php">Page 2</a></p>
The in page2.php, a user can check which days it has entered:
<?php
session_start();
// loop through the session array with foreach
foreach($_SESSION['days'] as $key=>$value)
{
// and print out the values
echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />';
}
?>
But I cant make the session connection correct, it is just blank. Is this the correct way of handling sessions with arrays?