well once that is set, it is set for the entire session. you aren't really testing where they came from, you are testing if they have visited the page once during this session.
if you truely want to make sure they came from a certain page, use $_SERVER['HTTP_REFERER'].
for example, all you need on the popup page is:
PHP Code:
<?
if ( strstr($_SERVER['HTTP_REREFER'], "mydomain.com/mypage.php") ) {
$whatever = "yes";
} else {
$whatever = "no";
}
?>
I use strstr to compare because the referer might be different if it's a page that has query variables in the url. i.e.
http://mydomain.com/mypage.php?f=1&b=2