This can be done using sessions.
First you need to start a session, assign a session array to a random function, then a variable from that session array.
<?php session_start(); $_SESSION['var'] = rand(10,20); $var = $_SESSION['var'];
You can then use this on subsequent pages, while you also start a session on these pages.
Link:
Example:
File 1
<?php session_start(); $_SESSION['var'] = rand(10,20); echo $var = $_SESSION['var'];
File 2
<?php session_start(); echo $var = $_SESSION['var'];
Sidenote:
Make sure there is nothing higher than this, as this may cause notification of sent headers.
If you received it, go to the next page on Stack:
source share