I don't see SESSION vars when calling subdomain script with jQuery (ajax)

I have a problem. Hope you can help me solve this problem.

I am creating a chat with LONG POLLING. To keep the main ajax requests in the domain (send a message) unqueued, I had to put my long polling script in a subdomain. So, I have 2 "domains"

foo.cz channel.foo.cz

I don't mind any of the same origin policies right now when I put

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

at the top of this script. I also use

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

in all scenarios (sending, receiving, talking).

For debugging, I have this in my .foo.cz / getNews.php channel:

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

My problem:

  • I'm loading a chat room
  • Ajax requests (jquery): channel.foo.cz/getNews.php
  • getNews.php returns this:

    Array () Array ()

  • , cookie . ! cookie FF, , cookie, chatRoom, .foo.cz
  • ajax- uri URL- ,

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

? !

+1
2

. cookie iframe, . , . ? php.ini:

suhosin.session.cryptdocroot=Off

suhosin.cookie.cryptdocroot=Off
+1
+1

Source: https://habr.com/ru/post/1656042/


All Articles