PHP HttpRequest Cookie 问题
我有一段代码要登录来测试网站登录: $r = new HttpRequest($newlocation, HttpRequest::METH_GET); $r->addCookies($cookieArray); $r->发送();
$cookieArray 的内容来自重定向,但我不会以任何方式修改它。 真正棘手的部分是,如果 cookie(身份验证令牌字符串)的值包含斜杠,则无法正确登录。如果它没有斜杠,一切正常。
任何想法表示赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试在传递值之前对其进行 urlencode() 解析,并在访问 cookie 时尝试对其进行 urldecode() 解析。我认为斜杠和饼干玩起来不太好。
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.
您是否尝试过序列化和 urlenconding cookie 数据?
Have you tried serializing and urlenconding the cookies data?
可能是 magic_quotes 问题,双重削减它,它会修改整个 cookie 值。否则,使用 array_walk 来分割 cookieArray 并像 Ben 建议的那样对其进行 URL 编码。
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.