NYCPHP Meetup

NYPHP.org

[nycphp-talk] Problem With Making Cookies

IAlsoAgree at stny.rr.com IAlsoAgree at stny.rr.com
Wed Apr 12 12:43:49 EDT 2006


Actually, I had been using implode as stated.

On another note, _ worked although I continued to have a lot of trouble.
While I could extract information from the cookie, my script seemed to
be refusing to use it until I noticed that I had done a test on part of
the cookie which should be (and infact was) 1, checking to see if it was
not equal to 1 using !=. Apparently, even though it was evaluating 1 !=
1 it was getting "true." Setting it to 1 == 1 now returns false. I'm not
sure why, but at least it works properly now.

Thanks,
-Joe

----- Original Message -----
From: Chris Shiflett <shiflett at php.net>
Date: Wednesday, April 12, 2006 7:35 am
Subject: Re: [nycphp-talk] Problem With Making Cookies
To: NYPHP Talk <talk at lists.nyphp.org>

> IAlsoAgree at stny.rr.com wrote:
> > $cookiedata = $infoarray[0].'#'.$infoarray[1].'#'.$infoarray[2];
> 
> You should definitely check out implode().
> 
> > However, when I actually check the data inside the cookie, it's
> > saved not with pound signs in between the data, but instead with
> > %23.
> 
> That's something setcookie() does. You can use header() if you want 
> to 
> have precise control over your Set-Cookie header. Try this example:
> 
> <?php
> 
> 
> $info = array();
> $info[] = 'one';
> $info[] = 'two';
> $info[] = 'three';
> 
> 
> $cookie = implode('#', $info);
> 
> 
> header("Set-Cookie: foo=$cookie");
> setcookie('bar', $cookie);
> 
> 
> ?>
> 
> The headers I see are:
> 
> Set-Cookie: foo=one#two#three
> Set-Cookie: bar=one%23two%23three
> 
> Hope that helps.
> 
> Chris
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> New York PHP Conference and Expo 2006
> http://www.nyphpcon.com
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
> 



More information about the talk mailing list