I have a main domain with site files at: mysite.com/users
I have subdomain: company1.mysite.com
Subdomain document root is: mysite.com/users
Login code:
function checkPassword($user, $password)
{
//DO STUFF TO CONFIRM PASSWORD, IF OK:
session_name("mysite_session");
session_set_cookie_params(0, '/', '.mysite.com');
session_start();
$_SESSION["user_id"] = $row["_id"];
$_SESSION["user_name"] = $user;
$_SESSION["loggedin_time"] = time();
}
At loading of all other pages:
<?php
...
session_name("mysite_session");
session_set_cookie_params(0, '/', '.mysite.com');
session_start();
//GET SESSION VARIABLES HERE AND CHECK FOR TIMEOUT
?>
If I load the site directly from mysite.com/users, everything works fine. If I try to load the company1.mysite.com, the sessions are not synced.
UPDATE: I should note that I do not have access to the servers php.ini file, which is required for most of the other solutions presented.
Also, I should add that there is no actual code on the subdomain. It simply refers to the main domains User folder