Re: [PHP] Cookies on WinXP

2003-07-31 Thread Curt Zirzow
* Thus wrote Chris Shiflett ([EMAIL PROTECTED]):
> --- Steve Buehler <[EMAIL PROTECTED]> wrote:
> > Something else I found out now.  I think it was Cpt John W. Holmes
> > (not sure though) that said I couldn't have a cookie as an array
> > like this the following. So i am not sure if it is something that
> > is going away or not.
> > setcookie ("admin_access[host]", "$cookhost",0,"/","$cookhost");
> > setcookie ("admin_access[hostName]", "$hostName",0,"/","$cookhost");
> 
> No, this is fine, as I mentioned previously. Yes, I recall someone saying you
> could not do this, claiming the name was invalid by referencing 2109, but I
> thought I replied and corrected them. My apologies if I failed to do so.

I was the one stating rfc2109, and only suggesting that might be
the problem. And yes the reply did come through.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] Cookies on WinXP

2003-07-31 Thread Chris Shiflett
--- Steve Buehler <[EMAIL PROTECTED]> wrote:
> Something else I found out now.  I think it was Cpt John W. Holmes
> (not sure though) that said I couldn't have a cookie as an array
> like this the following. So i am not sure if it is something that
> is going away or not.
> setcookie ("admin_access[host]", "$cookhost",0,"/","$cookhost");
> setcookie ("admin_access[hostName]", "$hostName",0,"/","$cookhost");

No, this is fine, as I mentioned previously. Yes, I recall someone saying you
could not do this, claiming the name was invalid by referencing 2109, but I
thought I replied and corrected them. My apologies if I failed to do so.

Actually, I just searched and found the link:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=20030730231223.3962.qmail%40web14303.mail.yahoo.com

I may write up a detailed explanation of cookies sometime, since they are a
somewhat confusing topic (especially with the odd use of words we use, such as
setting a cookie). Since they are essentially an extension of the HTTP
protocol, it helps to understand the architecture of the Web a bit more to
really grok the subject

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



Re: [PHP] Cookies on WinXP

2003-07-31 Thread Chris Shiflett
--- Steve Buehler <[EMAIL PROTECTED]> wrote:
> Well, if I take off the "string domain" part, it will work just
> fine.

This is what I was trying to explain. The cookie wasn't being returned, because
the browser didn't think the hostname matched. By leaving it out, the browser
will use whatever it thinks the current hostname is, so it's sure to match.

You're also right about the order of setcookie() - the parameters are optional,
but since they are based on order, you can't selectively leave any out except
in between.

If you want to be able to specify whatever cookie restrictions you want, you
can always use header(). Both functions modify the HTTP headers; the only
difference with manually writing your own is that you could screw up the
formatting. My opinion on that is that you could screw up the formatting of the
values of setcookie() anyway, so it doesn't necessarily save you. :-) In short,
use header() if you require the flexibility, and use setcookie() if you want a
bit of help and abstraction.

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



Re: [PHP] Cookies on WinXP

2003-07-31 Thread Steve Buehler
Something else I found out now.  I think it was Cpt John W. Holmes (not 
sure though) that said I couldn't have a cookie as an array like this the 
following.  So i am not sure if it is something that is going away or not.
setcookie ("admin_access[host]", "$cookhost",0,"/","$cookhost");
setcookie ("admin_access[hostName]", "$hostName",0,"/","$cookhost");

But I found the following on the php site at:
http://us3.php.net/manual/en/function.setcookie.php
-snip-
   * Cookies names can be set as array names and will be available to your 
PHP scripts as arrays but seperate cookies are stored on the users system. 
Consider explode() or 
serialize() to set one 
cookie with multiple names and values.


// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value \n";
}
}
/* which prints

three : cookiethree
two : cookietwo
one : cookieone
*/
?>
-end snip
I want to thank everybody for your help.

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


Re: [PHP] Cookies on WinXP

2003-07-31 Thread Steve Buehler
h.  Just found out what was wrong.  These are the specs that php.net 
says a setcookie function can have:
setcookie ( string name [, string value [, int expire [, string path [, 
string domain [, int secure])
Well, if I take off the "string domain" part, it will work just fine.  The 
problem is that I can't use the "int secure".  No biggy right now, but I 
might want to do that in the future.  So the following works just fine now:
setcookie("aa_host",$cookhost,'0','/');
Can anybody explain this now?  BTW, I put on an actual domain name to my 
laptop and put that domain name in the "string domain" parameter and it 
still didn't work.

Steve

At 05:53 PM 7/31/2003 -0500, Steve Buehler wrote:
I still can't figure something out.  I am using WinXP/Apache 1.3.24/PHP 
4.2.3 on my laptop and my cookies still don't work like they 
should.  Hopefully someone can explain to me why.

$cookhost=$_SERVER["HTTP_HOST"];
header("Set-Cookie: aa_host=$cookhost;");
setcookie ("aa_host", "$cookhost",0,"/","$cookhost");
setcookie ("aa_host", "localhost",0,"/","localhost");
setcookie ('aa_host', 'localhost',0,'/','localhost');
?>

I can set the cookie with the "header" line with no problem, but either 
one of the "setcookie" lines will not set the cookie.  Has anybody seen 
this?  Does anybody know why this might be happening?  BTW, no, I do not 
try to set all of these at once.  Just showing the lines that I use.  The 
"header" line and the first two "setcookie" lines work just fine on a 
RedHat 7.3/Apache 1.3.27/PHP 4.2.2 machine.

Thanks
Steve


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


Re: [PHP] Cookies on WinXP

2003-07-31 Thread Chris Shiflett
--- Steve Buehler <[EMAIL PROTECTED]> wrote:
> $cookhost=$_SERVER["HTTP_HOST"];
> header("Set-Cookie: aa_host=$cookhost;");
> setcookie ("aa_host", "$cookhost",0,"/","$cookhost");
> setcookie ("aa_host", "localhost",0,"/","localhost");
> setcookie ('aa_host', 'localhost',0,'/','localhost');
...
> I can set the cookie with the "header" line with no problem,
> but either one of the "setcookie" lines will not set the cookie.

Hi Steve,

You're not specifying a hostname in your header() example, but you are in each
of the setcookie() examples (and randomly switching between using $cookhost as
a value or as a hostname).

My advice is to check out http://www.php.net/setcookie and paying close
attention to:

1. The order of the parameters
2. The fact that they are not all required

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

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



Re: [PHP] Cookies on WinXP

2003-07-31 Thread Jeff Harris
On Jul 31, 2003, "Steve Buehler" claimed that:

|I still can't figure something out.  I am using WinXP/Apache 1.3.24/PHP
|4.2.3 on my laptop and my cookies still don't work like they
|should.  Hopefully someone can explain to me why.
|
|
|I can set the cookie with the "header" line with no problem, but either one
|of the "setcookie" lines will not set the cookie.  Has anybody seen
|this?  Does anybody know why this might be happening?  BTW, no, I do not
|try to set all of these at once.  Just showing the lines that I use.  The
|"header" line and the first two "setcookie" lines work just fine on a
|RedHat 7.3/Apache 1.3.27/PHP 4.2.2 machine.
|
|Thanks
|Steve

1st, what is the difference between what you are expecting and what you
are getting?

2nd, you do realize that since you're setting the cookies to have an
expiration of 0, that will delete the cookies when the brower is closed.

3rd, you know that you can't pick up the cookies in the same page where
they are set.

try letting some defaults persist to track downm errors:
setcookie ("aa_host", $cookhost,time()+3600);

Jeff
-- 
Registered Linux user #304026.
"lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import"
Key fingerprint = 52FC 20BD 025A 8C13 5FC6  68C6 9CF9 46C2 B089 0FED
Responses to this message should conform to RFC 1855.



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



Re: [PHP] Cookies on WinXP

2003-07-31 Thread Tom Rogers
Hi,

Friday, August 1, 2003, 8:53:51 AM, you wrote:
SB> I still can't figure something out.  I am using WinXP/Apache 1.3.24/PHP 
SB> 4.2.3 on my laptop and my cookies still don't work like they 
SB> should.  Hopefully someone can explain to me why.
SB>  $cookhost=$_SERVER["HTTP_HOST"];
SB> header("Set-Cookie: aa_host=$cookhost;");
SB> setcookie ("aa_host", "$cookhost",0,"/","$cookhost");
SB> setcookie ("aa_host", "localhost",0,"/","localhost");
SB> setcookie ('aa_host', 'localhost',0,'/','localhost');
?>>

SB> I can set the cookie with the "header" line with no problem, but either one 
SB> of the "setcookie" lines will not set the cookie.  Has anybody seen 
SB> this?  Does anybody know why this might be happening?  BTW, no, I do not 
SB> try to set all of these at once.  Just showing the lines that I use.  The 
SB> "header" line and the first two "setcookie" lines work just fine on a 
SB> RedHat 7.3/Apache 1.3.27/PHP 4.2.2 machine.

SB> Thanks
SB> Steve

try setting up a domain on your laptop, add this to the hosts file

127.0.0.1   mylaptop.com
127.0.0.1   www.mylaptop.com

Then use that instead of localhost, maybe it will be better with a
real looking domain.

-- 
regards,
Tom


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