Re: [PHP] Repeat : I'm Living in cookie hell....

2001-05-12 Thread barce

Hello Scott,

I took a look at your code, and have a solution for you.

Here's the code:

while ($row = mysql_fetch_array($result) )
{
if ($row[memberid] == $login_id)
{
// your code here :-)
}
}

 
$row = mysql_fetch_array($result); // Get one row of data only *BAD*
if ($row[memberid] == $login_id) {
   // [...]
}
 
 the path of the cookie to be the root under both instances, it should be
 trying to set the same cookie, right?

correct, but this only works if the first array returned is equal to the
login_id. since you are returning only the first row of your database
table, you never make it to the memberid that you're hoping is there --
assumming that it is there.

Train harder!

regards,barce

-- 
PHP General 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]




RE: [PHP] Repeat : I'm Living in cookie hell....

2001-05-12 Thread Scott Brown


Thanks for your reply.

Unfortunately, the problem is not in getting the code to execute - I know it
is for two reasons:

1) the setcookie(...) is being triggered because I have cookie warnings
turned on in the browser, and it warns me that a new cookie is being
received and it shows me the expected content of the cookie

2) the reloacation via the header is occuring as expected.

It's just that the cookie being set isnt being retained on the browser

(oh - and as a side note, there would only ever be 1 match for the returned
mysql result... which is why I didnt loop through them... there's either a
row returned, or not... and if not, then the rest of the code that wasnt
included in the msg handles that situation)

What I'm wondering though, is in the page which sets the cookie ok,
there is no redirection it executes:

setcookie(YONKAMEMBERID,$insert_id,time()+31536000,/,$PHP_HOST);

inline, and then displays the page.

In the page which doesnt set the cookie, there is redirection occuring

setcookie(YONKAMEMBERID,$login_id,time()+31536000,/,$PHP_HOST);
Header(Refresh: 0;url=/);

It's the exact same code -- just a different variable setting the value, and
the header call afterwards. (though even when I comment out the header(..)
it still doesnt work.)

Something just isnt right somewhere.

Is it the path of the script being exeuted that's causing something strange
to occur??

I really am at a loss

 Hello Scott,

 I took a look at your code, and have a solution for you.

 Here's the code:

 while ($row = mysql_fetch_array($result) )
 {
   if ($row[memberid] == $login_id)
   {
   // your code here :-)
   }
 }

 
 $row = mysql_fetch_array($result); // Get one row of
 data only *BAD*
 if ($row[memberid] == $login_id) {
  // [...]
 }
 
  the path of the cookie to be the root under both instances,
 it should be
  trying to set the same cookie, right?

 correct, but this only works if the first array returned is
 equal to the
 login_id. since you are returning only the first row of your database
 table, you never make it to the memberid that you're hoping
 is there --
 assumming that it is there.

 Train harder!

 regards,barce

 --
 PHP General 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]




-- 
PHP General 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]




[PHP] Repeat : I'm Living in cookie hell....

2001-05-11 Thread Scott Brown

(it's been about 12 hours since I sent this, and havent seen it come
through, so I'm re-building/re-sending it... 'cause I need some help on
this)

I'm confused.  I'm bemuttered.  I'm pulling my hair out.

I have a page which processes a membership request, and includes the
following code:

from /secure/membersignup.php  (will eventually live under an SSL
connection)

   if (!mysql_query($sql))
$insert_id = 0;
   else {
$insert_id = mysql_insert_id($connTemp);
setcookie(YONKAMEMBERID,$insert_id,time()+31536000,/,$PHP_HOST);
   }

It quite nicely sets the cookie, and the cookie is accessible from any page
on the site.  I know this because (a) I turn on the cookie warnings, and
examine the cookie contents being set, and (b) the cookie contents are
actually thrown out in the header of all my pages (well, any subsequent
pages... I know the limit on cookie processing in PHP).  The cookie is
accessible in any script's subdirectory that I've tried.

Next, I also have a log out page, which unsets the cookie using this code:

from /logout.php

setcookie(YONKAMEMBERID,,time()-1,/);

which quite happily works and after processing, the cookie is no longer set,
and the data is not thrown into the headers of all my pages.

Now comes my problem : I have a page to allow the user to login to the
site (reset the cookie to their membership#)...

from /login.php

   $row = mysql_fetch_array($result);
   if ($row[memberid] == $login_id) {
  $bad_attempt=0;

setcookie(YONKAMEMBERID,$login_id,time()+31536000,/,$PHP_HOST);
  Header(Refresh: 0;url=/);
   }

This code does NOT set the cookie.  The only differences here are the
variable name setting it (which must be valid membership ID# otherwise the
database comparison would not work, and the page would not refresh back to
the main index page.) and the path of the script... but since I'm defining
the path of the cookie to be the root under both instances, it should be
trying to set the same cookie, right?

I've even goen so far as scrape the line out of the working code and insert
it into the login page (then changing the variable)... and it still doesnt
work.

Does anyone have any suggestions?

I'm testing with IE 5.01 SP1, and using PHP4.04pl1 on the backend. I
havent tried under netscape yet.



-- 
PHP General 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]