session_start();
at the top of every page, then to set a variable:
$_SESSION['id']=OurID();
and $id=$_SESSION['id'];
to access it,.
the 'global' keyword isn't what you're talking about...
[edit]
re-reading leaves me a buit confused.
The above will alow access to the variable between pages for the length of a session. For access within one page, passing it to any functions that need it is the best way, or if you really insist:
Code:
$id=OurID();
//some code that does things
makeAdvert();
///etc.
function makeAdvert() {
global $id;
///you can use $id here and changes to itwill persist
}