我没有看到SESSION vars当调用子域脚本与Jquery(ajax) [英] I do not see SESSION vars when calling subdomain script with Jquery (ajax)
问题描述
我有一个问题。我希望你能帮我解决它。
I've got a problem. I hope you'll help me to solve it.
我正在与LONG POLLING聊天。为了保持主域ajax请求(发送消息)未变动(未排队),我不得不把我的长轮询脚本子域。
所以我有2个域
I'm creating chat with LONG POLLING. To keep main domain ajax requests (send message) untouched (unqueued), I had to put my long-polling script to subdomain. So I've got 2 "domains"
foo.cz
channel.foo.cz
foo.cz channel.foo.cz
我不介意任何同源策略现在我把
I do not mind about any Same Origin Policy right now as I put
header("Access-Control-Allow-Origin: *");
我也使用
ini_set('session.cookie_domain', '.foo.cz');
。
对于调试,我在我的channel.foo.cz/getNews.php中有这个:
For debugging, i've got this in my channel.foo.cz/getNews.php:
print_r($_SESSION);
print_r($_COOKIE);
die();
我的问题是:
- 我会加载聊天室
- Ajax(jquery)请求channel.foo.cz/getNews.php
- .php返回:
- I do load chatting room
- Ajax (jquery) requests channel.foo.cz/getNews.php
getNews.php returns this:
array()array()
array()array()
如果我尝试复制ajax请求uri并粘贴到浏览器网址,它返回我
If I try to copy ajax request uri and paste it into browser url, it returns me
array([username] => martin)array([SESSID] => some1D65a4s6d54asd)
array([username] => martin)array([SESSID] => some1D65a4s6d54asd)
怎么可能?很抱歉,很长的问题,并感谢所有的答案!
How is that possible? Sorry for long question and thanks for all answers!
推荐答案
我有它。
浏览器限制发送cookie到另一个子域
所以我使用了iframe发送请求到我的子域。然而,有一些问题,当有消失的会话。解? php.ini:
I've got it. Browser is restricting to send cookies to another subdomain So I have used iframe which is sending request to my subdomain. However, there were some problem when there were vanishing sessions. Solution? php.ini:
suhosin.session.cryptdocroot=Off
suhosin.cookie.cryptdocroot=Off
这篇关于我没有看到SESSION vars当调用子域脚本与Jquery(ajax)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!