I do not see SESSION vars when calling subdomain script with Jquery (ajax)

Discussion in 'PHP' started by G3n3s!s, May 23, 2011.

  1. #1
    Hello. 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!
     
    G3n3s!s, May 23, 2011 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    is this hosted on to one box? you domain and subdomain?
     
    bartolay13, May 24, 2011 IP