I have 2 almost identical php header scripts, both of which work beautifully
online through my Linux Server.  However, one does not through my Windows 98
localhost.  The first 45 lines of both scripts are identical and appear
below my signature if you need to see them.  The snippets below began at
line 46 in each instance.

<snippet_1>
 SetCookie ("agent", "$agent");
 SetCookie ("ver", "$version"); /* Opera ignores $version as a cookie_name
*/
 SetCookie ("major", "$major");
 SetCookie ("minor", "$minor");

 header("Location: http://localhost/Apache/htdocs/cookietext.php";);
 exit;
?>/* EOF - This remark not in doc */
</snippet_1>

<snippet_2>
 SetCookie ("agent", "$agent");
 SetCookie ("ver", "$version"); /* Opera ignores $version as a cookie_name
*/
 SetCookie ("major", "$major");
 SetCookie ("minor", "$minor");

 if (($agent != "Netscape") || ($version > 5.00)) {
  header("Location: http://localhost/Apache/htdocs/cookietext.php";);
  exit;
 }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html> /* Valid document below */
</snippet_2>

The redirects work without a problem in both cases. However, when run
through localhost, the cookie variables are not usable by cookietext.php in
the case of <snippet_2>.  Wherever I try to make use of these variables, I
receive an undefined variable error.  Reloading or refreshing does no good.
The behavior is universal across all browsers tested.

It appears, in the case of snippet_2, that the cookie variables are either
not being set or localhost is not recognizing the redirect as an HTTP
request. The question is, WHY?  I am hoping that it is a simple
configuration problem and that some kind soul on this group has the answer.

TIA,
Bill

<lines 1_45>
<?
 $reUA = "/^(\w+)\/((\d+).(\d+))/";
  $reIE = "/(MSIE) ((\d+).(\d+))/";
 $reNS6 = "/(Netscape)\d*\/((\d+).(\d+))/i";
 $reOpera = "/(Opera) ((\d+).(\d+))/i";
  $reWebTV = "/(WebTV)\/((\d+).(\d+))/i";

  preg_match($reUA, $HTTP_USER_AGENT, $RegExp);
  $agent   = $RegExp[1];
  $version = $RegExp[2];
  $major   = $RegExp[3];
  $minor   = $RegExp[4];

  if (preg_match($reIE, $HTTP_USER_AGENT, $RegExp)) {
    $agent   = $RegExp[1];
    $version = $RegExp[2];
    $major   = $RegExp[3];
    $minor   = $RegExp[4];
  }

  if (preg_match($reNS6, $HTTP_USER_AGENT, $RegExp)) {
    $agent   = $RegExp[1];
    $version = $RegExp[2];
    $major   = $RegExp[3];
    $minor   = $RegExp[4];
  }

  if (preg_match($reOpera, $HTTP_USER_AGENT, $RegExp)) {
    $agent   = $RegExp[1];
    $version = $RegExp[2];
    $major   = $RegExp[3];
    $minor   = $RegExp[4];
  }

  if (preg_match($reWebTV, $HTTP_USER_AGENT, $RegExp)) {
    $agent   = $RegExp[1];
    $version = $RegExp[2];
    $major   = $RegExp[3];
    $minor   = $RegExp[4];
  }

 if (($agent=="Mozilla") && ($version > 4.00) && ($version < 5.00)) {
   $agent = "Netscape";
 }

</lines 1-45>




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to