thyseus / yii-user-management

a user management module collection for the yii framework
186 stars 122 forks source link

Cant have user logged in between subdomains with hybridauth. #178

Open eleiva opened 10 years ago

eleiva commented 10 years ago

Hi All!

I'm working in a multidomain site and i need to maintain user logged in between sub-domains.

So I have this config in my main.php

  'session' => array(
        'savePath' => '/tmp',
        'cookieMode' => 'allow',
        'cookieParams' => array(
            'path' => '/',
            'domain' => 'mydomain.com',
            'httpOnly' => true,
        ),

It works great, i can login in foo.mydomain.com and stilll logged in when access another.mydomain.com, so only left to do the same with hybridauth .

So i change baseUrl in hybridauth.php ( config )

return 
  array(
    "base_url" => "http://".$_SERVER['SERVER_NAME'] ."/hybridauth.php",
...

But i get

You cannot access this page directly.

The problem seems to be in the session. When i remove yii session config detailed before, i could login with both domains but without sharing info ( i have to login twice first in foo.mydomain.com and next in another.mydomain.com )

Any Ideas?

SacDin commented 9 years ago

I came across the same problem and figured out this way :

Go to Storage.php file in your Hybrid extension directory and add following line on top in the __construct() method

session_set_cookie_params(0, '/', '.yourdomain.com');

Eureka !