php - Save user input in a variable and use it on all pages


As described above I want the user to enter any value like "minutes" in a form and use it on another page to set a timer.
In order to do that I should use php. I have seen and searched many examples, but I can't find any actual way to use a variable in all of the web pages One example I ran into, was to use:

<?php include"form.php" ?>

but it also prints the content on it by default.

Now what I truly want is:

A variable $minutes = 3; Which will be the default value stored somewhere or maybe even on the form page. I have a form page on which I take the minutes as input from a user and on clicking the submit button the value of $minutes changes into the value provided by the user. Now he can change it again and again and again to 2 minutes, 5 minutes etc etc, but I have no way to send it across multiple pages.

Thank you for your help




To have access to your variable on every single of your pages you could store your variable in a session :

 $_SESSION['minutes'] = 3;

// rest of your code

and you can access it like that :


or in a cookie :

 setcookie("minutes", 3);

which you can access this way :


People are also looking for solutions to the problem: Why does my Php Image upload not work?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.