Re: Cookie Gets destroyed

From: Date: Tue, 22 Apr 2003 09:25:55 +0000
Subject: Re: Cookie Gets destroyed
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-144791@lists.php.net to get a copy of this message
At 21:53 22-4-03, you wrote:
i am having problem with cookies.the script worked well on local server.but now its giving me all sorts of problems. the cookie get set but when i redirect it to another page there isn't any cookie left. here the script Check login and cookies here /*************************************************************************** ****************************/ if (isCookiesEnabled() && setcookie("var1","") && setcookie("var2","") && setcookie("var3","")) {
       // checking if the client is accepting cookies
       // now that we know that the user is accepting cookies
       // so we set some cookies and then redirect
       if (setcookie("var1",$va1,time()+1800) &&
setcookie("var2",$var2,time()+1800) && setcookie("var3",$var3,time()+1800)) make sure $va1 ($var1?) and $var2 and $var3 have a value, as an empty value automatically means the cookie is destroyed.
        {
             echo "<meta HTTP-EQUIV=\"refresh\" CONTENT=\"0;
URL=checklogin.php\">";
             exit;
        }
       else
        {
         Go("login.php?nErr=700",1); // the cookie has been destroyed
         exit;
        }
      }
/*************************************************************************** *********************************/ if ($_COOKIE['var1'] && $_COOKIE['var2'] && $_COOKIE['var2']) You are checking on all cookies
what if $va1 (above in your code) was a typing error? then that would be a false. Try to show the value of the cookies while developing this test.
    {
         header("location:pagename.php");
         exit;
    }
else
    {
     header("location:login.php"); // the cookie has been destroyed
     exit;
    }
/*************************************************************************** *******************************/ thanx in advance Haseeb -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#144791) next »