0

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

Josh
  • 2,685
  • 6
  • 33
  • 47
  • 1
    Possible duplicate of [PHP Sessions across sub domains](http://stackoverflow.com/questions/1064243/php-sessions-across-sub-domains) http://stackoverflow.com/questions/644920/allow-php-sessions-to-carry-over-to-subdomains – zod Jan 20 '17 at 21:54
  • I should note that those solutions require access to php.ini, which I do not have. – Josh Jan 20 '17 at 23:57
  • Well, unfortunately, just because you don't have access to htaccess doesn't mean that you can fix it another way. PHP works the way it works, and there's only so many ways to overcome a problem like this... – random_user_name Jan 21 '17 at 00:20
  • I do have access to htaccess, and I've attempted to allow access that way with no luck. – Josh Jan 21 '17 at 02:23
  • after the change in ini did you restart the webserver – zod Jan 23 '17 at 18:00

0 Answers0