Is it possible to store a different value in to a session variable in php for
example I have a post variable called $_POST['sit'] which takes different values every time the user submits a form , I want to store all the different values that the post variable will take until the user stop submitting the form , how can I store all the different values of the post variable in to a session variable array
Add a comment
|
1 Answer
You will need to start the session, check for the existence of the post variable, and then push into an array stack within the session. here's psuedo-code:
session_start();
if(isset($_POST['sit'])){
$_SESSION['sits'][] = $_POST['sit'];
}
Now when you var_dump($_SESSION['sits']) it will hold reference to all of the posted values from $_POST['sit']