where is my $_SESSION ['page']?
<p>in this web crawler, i don't understand where the session variable 'page' comes from? anyone got any ideas. it gathers all urls from a given web page and i am trying to decipher what it does. i have done well but i wonder a) where $_SESSION['page'] comes from? b) why $_SESSION [i] is incremented in an if statement.</p>

<pre><code> &lt;?php

  session_start();

 $domain = "www.ebay.com";

  if(empty($_SESSION['page']))
  {
 $original_file = file_get_contents("http://" . $domain . "/");

 $_SESSION['i'] = 0;

  $connect = mysql_connect("xxx", "xxx", "xxxx");

  if (!$connect)
  {
  die("MySQL could not connect!");
 }

 $DB = mysql_select_db('xxx');

  if(!$DB)
 {
  die("MySQL could not select Database!");
   }
 }
   if(isset($_SESSION['page']))
    {

   $connect = mysql_connect("xxxx", "xxx", "xxx");

   if (!$connect)
 {
    die("MySQL could not connect!");
 }

  $DB = mysql_select_db('xxx');

    if(!$DB)
    {
 die("MySQL could not select Database!");
 }
   $PAGE = $_SESSION['page'];
    $original_file = file_get_contents("$PAGE");
      }

    $stripped_file = strip_tags($original_file, "&lt;a&gt;");
     preg_match_all("/&lt;a(?:[^&gt;]*)href=\"([^\"]*)\"(?:[^&gt;]*)&gt;(?:[^&lt;]*)&lt;\/a&gt;/is", $stripped_file, $matches);

    foreach($matches[1] as $key =&gt; $value)
    {

    if(strpos($value,"http://") != 'FALSE' &amp;&amp; strpos($value,"https://") != 'FALSE')
    {
     $New_URL = "http://" . $domain . $value;
       }
     else
       {
      $New_URL = $value;
          }
      $New_URL = addslashes($New_URL);
      $Check = mysql_query("SELECT * FROM pages WHERE url='$New_URL'");
       $Num = mysql_num_rows($Check);

       if($Num == 0)
       {
      mysql_query("INSERT INTO pages (url)
      VALUES ('$New_URL')");

       $_SESSION['i']++;

      echo $_SESSION['i'] . "";
       }
         echo mysql_error();
        }

 $RandQuery = mysql_query("SELECT DISTINCT * FROM pages ORDER BY RAND() LIMIT 0,1");
 $RandReturn = mysql_num_rows($RandQuery);
  while($row1 = mysql_fetch_assoc($RandQuery))
     {
    $_SESSION['page'] = $row1['url'];
    }


    echo $RandReturn;
    echo $_SESSION['page'];
    mysql_close();

         ?&gt;
</code></pre>
