1

I've got a problem. I hope you'll help me to solve it.

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

I do not mind about any Same Origin Policy right now as I put

header("Access-Control-Allow-Origin: *");

at top of that script. I also do use

ini_set('session.cookie_domain', '.foo.cz');

in all scripts (sending, receiving, chatting room).

For debugging, i've got this in my channel.foo.cz/getNews.php:

print_r($_SESSION);
print_r($_COOKIE);
die();

My problem is:

  1. I do load chatting room
  2. Ajax (jquery) requests channel.foo.cz/getNews.php
  3. getNews.php returns this:

    array()array()

  4. It look that cookies and session isn't setted up. But! If I look into my FF cookie browser, I do see that domain for these cookies set in chatRoom is .foo.cz
  5. If I try to copy ajax request uri and paste it into browser url, it returns me

    array([username] => martin)array([SESSID] => some1D65a4s6d54asd)

How is that possible? Sorry for long question and thanks for all answers!

2 Answers 2

1

You need to look at session_set_cookie_params function's third parameter. It sets the domain name where the cookie with SID is valid in.

Sign up to request clarification or add additional context in comments.

6 Comments

I said that there is ini_set('session.cookie_domain', '.bidmanie.cz'); When I look into FF cookie browser I see correct domain. I now noted that jquery DOES NOT SEND SESSION ID, so I'm receiving new session ID everytime!
So it looks like rather some Javascript or jQuery bug.
I tried this: .ajax({timeout: 52000,headers: {Cookie: "PHPSESSID="+SSID},url:'channel.foo.cz/getNews.php?__='+SSID}); but request header doesn't change (no cookie: header specified)
BTW Ondeji, could you give me some contact, like Skype? I would like if you could help me directly, we're speaking in same language (CZ) ;)
No, sorry. I don't like giving my private contact info, because you have much bigger probability of getting the answer if you ask on a public site like SO. Also, I like to answer questions voluntarily and not if I'm forced to by asking directly on IM. Thanks for understanding.
|
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.