1

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

1 Answer 1

2

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']

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.