change session variable value on another page
I want the $_SESSION['userShort'] value to change when the if condition is met in the register.act.php page, so that the value is different even in the register.php page, once the submit button in clicked in this same page, but I'm doing something wrong... REGISTER.PHP <?php session_start(); include 'includes/header.php' ?> <div class="container w-50 mx-auto"> <div class="alert alert-danger" <?php echo $_SESSION["userShort"] = 'style="display: none;"' ?>>The name is too short</div> <form action="action/register.act.php" method="POST"> <div class="form-group"> <label for="username">Username</label> <input type="text" name="username_reg" class="form-control"> <label for="pwd">Password</label> <input type="password" name="pwd_reg" class="form-control"> <button type="submit" name="submit_reg" class="mt-3 btn btn-success">Register</button> </div> </form> </div> </body> </html> <?php var_dump($_SESSION["userShort"]); ?> REGISTER.ACT.PHP <?php session_start(); if(isset($_POST['submit_reg'])){ if(strlen($_POST['username_reg']) < 8){ header('Location: ../register.php'); $_SESSION['userShort'] = "style='display: block;'"; } }