I have a example.com/login.php file on root domain with this code
header('Access-Control-Allow-Origin: *'); session_set_cookie_params(0, '/', '.example.com'); session_name('lusession'); session_start(); $_SESSION['name'] = $_GET['name']; $_SESSION['useremail'] = $_GET['useremail']; $_SESSION['password'] = $_GET['password']; This file is provided with credentials and it then creates login session. It is called from main domain and subdomains by AJAX.
The problem is it doesnot creat session when called through AJAX, but when opened directly in browser as querystring it creates cross domain session as expected.
Other pages which call it through AJAX have following code in them at start:
session_set_cookie_params(0, '/', '.example.com'); session_name('lusession'); session_start(); If I add following code in login.php it shows in AJAX response that session is created. But that session is not available on pages on same domain and on other subdomains.
echo 'session created for'.$_SESSION['name']; Inspecting resource shows AJAX call creates session cookie with name 'lusession' as it should.
session.cookie_httponly(or: the 5th parameter ofsession_set_cookie_params()if you will).