All you have to do, is to take the code below and save it to a file (ex, background.php)
<?php
session_start();
if(!$_SESSION['background'])
$_SESSION['background'] = 'background' . mt_rand(1, 5). '.jpg';
?>
and then to include it in your other PHP files, you can do something like this:
<?php
session_start();
include('background.php')
... rest of your code
?>
and then in your special <div>, you could do something like this: (or as mjax suggested)
<div style="background: url(<?=$_SESSION['background'];?>);">bla bla...</div>