okay, i know this is stupid, and i'm gonna kick myself when someone points
out the obvious...

i've just put a site online, and found the server's running an older version
of php (4.06). it's virtual hosting, so i have no control over this... also
can't tell you what OS it's running, but it is windows based...

the code works locally, although i had to change all $_COOKIE to
$HTTP_COOKIE_VARS, same with $_POST, $_SERVER, etc. etc.

i've had a quick look through the archives, and googled, but can't find much
help around for older installs of php.

my code, like i said, the functionality works, but it's just plain not
sending the cookie, my little print statements show up and all, but i get no
error, and i also get no cookie.

<?
 $error=2;
 require_once("../inc/db.inc.php");
 db_connect('babc');
 if(isset($HTTP_GET_VARS['logout']))
 {
  setcookie("UserName", "", time()-(60*60*24));
  setcookie("Password", "", time()-(60*60*24));
  print "logout";
  $error=2;
 }elseif(isset($HTTP_POST_VARS['login'])){
  $SQL = "...";
  $res = mysql_query($SQL) or die( mysql_errno." query error" );
  $numRows = mysql_num_rows($res);
  if($numRows==1)
  {
   extract(mysql_fetch_array($res));
   setcookie("UserName", $HTTP_POST_VARS['UserName'], time()+(60*10), "/",
$HTTP_SERVER_VARS['SERVER_NAME']);
   setcookie("Password", $password, time()+(60*10), "/",
$HTTP_SERVER_VARS['SERVER_NAME']);
   print "login - set cookie";
   $error=0;
  }else{
   $error=1;
  }
 }elseif (isset($HTTP_COOKIE_VARS ['UserName']) && isset($HTTP_COOKIE_VARS
['Password'])){
  $SQL = "...";
  $res = mysql_query($SQL) or die( mysql_errno." query error" );
  $numRows = mysql_num_rows($res);
  if($numRows==1)
  {
   extract(mysql_fetch_array($res));
   setcookie("UserName", $HTTP_COOKIE_VARS['UserName'], time()+(60*10), "/",
$HTTP_SERVER_VARS['SERVER_NAME']);
   setcookie("Password", $password, time()+(60*10), "/",
$HTTP_SERVER_VARS['SERVER_NAME']);
   print "already logged in";
   $error=0;
  }else{
   $error=1;
   setcookie("UserName", "", time()-(60*60*24));
   setcookie("Password", "", time()-(60*60*24));
   print "problem with login, logout";
  }
 }
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to