views:

131

answers:

3

I have a chunk of code to login to test a web site login: $r = new HttpRequest($newlocation, HttpRequest::METH_GET); $r->addCookies($cookieArray); $r->send();

The content of $cookieArray is from a redirect, but I don't modify it in any way. The really baked part is that if the value of the cookie (an authentication token string) contains a slash, it doesn't login properly. If it doesn't have a slash, everything works.

Any ideas are appreciated.

A: 

You could try urlencode()-ing the value before passing it, and urldecode()-ing it when the cookie is accessed. I think slashes and cookies don't really play very nice.

Ben Torell
A: 

Have you tried serializing and urlenconding the cookies data?

 $tmpdata = serialize($arraydata);
 $tmpdata = urlencode($tmpdata);
 setcookie($cookiename, $tmpdata, time()+3600*5, "/");
JeremySpouken
A: 

Could be a magic_quotes issue, double slasshing it, and it modifies the whole cookie value. Else, use an array_walk to part the cookieArray and URL encode it like Ben suggested.

Adrian A.