如何用PHP读取Javascript cookie [英] How to read Javascript cookie with PHP
问题描述
我正在做一个PHP脚本,它将像一个在现场的API,不提供一个。我使用curl它的网站是使用javascript发布Cookie,所以我不能读他们。
I'm making a PHP script that would work like an API on site that doesn't provide one. I'm using curl for it and the site is posting cookies with javascript, so I can't read them.
有一个PHP类或PHP模块, javascript,存储cookie,让我重新提交它与curl到所提到的页面?
Is there a PHP class or PHP module that would read javascript, store the cookie and let me resubmit it with curl to the mentioned page?
我读某处可能从Java读取PHP,也许有一个类似的方式为JS / PHP?
I read somewhere that it is possible to read PHP from Java, so maybe there is a similar way for JS/PHP?
推荐答案
你最好的赌注是尝试从php读取cookie。 Javascript不能和php本身交谈,但是php可以抓取javascript创建的cookie。
Your best bet is to try and read the cookie from php. Javascript can't talk to php itself, but php can grab a cookie that javascript has created.
http://php.net/manual/en/features.cookies.php 继续说:
从
客户端发送给您的任何cookie都将自动包含
到$ _COOKIE自动全局数组...
Any cookies sent to you from the client will automatically be included into a $_COOKIE auto-global array...
希望这有助于!
这篇关于如何用PHP读取Javascript cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!