通过AJAX将安全cookie传递给PHP
我正在实现LinkedIn,并且有一个支持SSL的页面,会员可以登录该页面,该页面根据文档将他们的oauth令牌存储在一个安全的“凭证”cookie中。然后,我试图通过jQuery通过AJAX将安全cookie传递给PHP,php,cookies,oauth-2.0,Php,Cookies,Oauth 2.0,我正在实现LinkedIn,并且有一个支持SSL的页面,会员可以登录该页面,该页面根据文档将他们的oauth令牌存储在一个安全的“凭证”cookie中。然后,我试图通过jQuery$.post()将这些cookie传递到PHP页面: 当我检查通过Firebug发送的数据时,我可以在jQuery帖子的标题中看到以下内容: Cookie: __utma=xxxx; __utmc=xxxx; __utmz=xxxx; linkedin_oauth_YYYY=yyyy; PHPSESSID=xxxx;
$.post()将这些cookie传递到PHP页面:
当我检查通过Firebug发送的数据时,我可以在jQuery帖子的标题中看到以下内容:
Cookie: __utma=xxxx; __utmc=xxxx; __utmz=xxxx; linkedin_oauth_YYYY=yyyy; PHPSESSID=xxxx; __utmb=xxxx
然而,在exchange.php页面上,通过执行print\r($\u cookie),只有不安全的cookie被公开(接收页面只能看到Google分析和php会话cookie)代码>:
你知道我做错了什么吗?我正在使用SSL发布到同一个域,但是exchange.php
脚本无法使用安全cookie
更新:
我现在也在exchange.php页面上回显$\u服务器值,有趣的是,我得到了以下结果:
Array
(
[HTTPS] => on
[HTTP_COOKIE] => __utma=xxxx; __utmc=xxxx; __utmz=xxxx; linkedin_oauth_YYYY=yyyy; PHPSESSID=xxxx; __utmb=xxxx
)
所以cookie被传递了,但没有在$\u cookie变量中设置?仅供参考,运行PHP 5.3.3。解决了这个问题-在我运行上述代码的服务器上,我已经安装了,并且它将请求和cookie索引的最大长度限制为64个字符-完整的未混淆linkedin_oauth_YYYY cookie索引比这个长度长。以下是我对php.ini所做的更改:
[suhosin]
suhosin.cookie.max_array_index_length = 256
suhosin.cookie.max_name_length = 1024
suhosin.cookie.max_totalname_length = 4096
suhosin.request.max_totalname_length = 4096
suhosin.request.max_varname_length = 1024
解决了这个问题-在我运行上述代码的服务器上,我已经安装了,并且它将请求和cookie索引的最大长度限制为64个字符-完整的未阻塞linkedin_oauth_YYYY cookie索引比这个长度长。以下是我对php.ini所做的更改:
[suhosin]
suhosin.cookie.max_array_index_length = 256
suhosin.cookie.max_name_length = 1024
suhosin.cookie.max_totalname_length = 4096
suhosin.request.max_totalname_length = 4096
suhosin.request.max_varname_length = 1024
[suhosin]
suhosin.cookie.max_array_index_length = 256
suhosin.cookie.max_name_length = 1024
suhosin.cookie.max_totalname_length = 4096
suhosin.request.max_totalname_length = 4096
suhosin.request.max_varname_length = 1024