session_start();
$r = range(1,10);
$random = ($_SESSION['random']) ? $_SESSION['random'] : 1;
$key = array_search($random, $r);
unset($r[$key]);
shuffle($r);
$_SESSION['random'] = $r[0];
echo $_SESSION['random'];
?>
// leave this so we can assign a session key/value pair to the last number used, must go at top of page before any other output
session_start();
// create a range of numbers between x and x to use as the seed
$r = range(1,10);
// if the session var is set, use it otherwise use 1 OR whatever the low range value is above
$random = ($_SESSION['random']) ? $_SESSION['random'] : 1;
// search for the $random value and remove it so we don't use it again without using another value first
$key = array_search($random, $r);
// deleting the value from this page load only
unset($r[$key]);
// shuffling the array for sequential random behavior
shuffle($r);
// creating a session var from $r to use as the array pointer
$_SESSION['random'] = $r[0];
// we're just echoing the result here. it can also be assigned to a var
echo $_SESSION['random'];