I have a site where once an administrator selects the user they want to view, I then put that userid into a session variable:
$_SESSION['vwuserid']
Which allows me to conveniently hang onto that variable throughout the site, until the admin selects a different user to view.
BUT within an individual page I may need to call on that variable as a query criteria 8 or 9 times, eg:
$query1 = "SELECT * FROM tablea WHERE userid='".$_SESSION['vwuserid']."'";
Question: Is it better (ie, more efficient/lighter load) to use the session variable repeatedly as above, or is there any gain in calling the session variable once and putting it in an ordinary variable, and then using that in the multiple queries, eg:
$vwuserid = $_SESSION['vwuserid'];
$query1 = "SELECT * FROM tablea WHERE userid='".$vwuserid."'";
$query2 = "SELECT * FROM tableb WHERE userid='".$vwuserid."'";
Any thoughts? I'd really like to tie this baby down as tight as I can.