How to Save a Random Number as a Session Variable in PHP
Posted on June 18, 2015 in PHP by Matt Jennings


If statement below saves a random number as session variable
so it won't change when a form is submitted multiple times
until the session is destroyed
    $_SESSION['rand_num_session'] = rand(1, 100);

$_SESSION['my_guess'] = $_POST['guess'];

header('Location: great-number-game.php');

Leave a Reply

To Top ↑