views:

462

answers:

2

Hi

I have two applications that both run separate instance of Zend Framework MVC application. They are hosted on different subdomains:

news.mydomain.com
member.mydomain.com

I use Zend_Auth on member.mydomain.com to handle authentication.

How do I configure ZF on news.mydomain.com to capture the auth info assigned in member.mydomain.com?

I know that we can configure cookie's "domain" parameter, but where/how do I do this in Zend_Auth?

thanks!

+3  A: 

You should be able to do this if you set the Zend_Session namespace to the same namespace in both applications. I believe you set it when you instantiate it the first time, for example:

$sess = new Zend_Session("Mynamespace");

As long as both applications run on the same machine, or you have some cross-system session stuff happening (for instance, memcached on multiple machines), they should both be able to access the same session variables.

If you do find where you set the domain, try setting it to:

.mydomain.com

instead of

mydomain.com

I remember some weirdness happening with multiple subdomains on my installation and that seemed to fix it.

Edit: I found where you set the domain for the user's session - oddly enough, it's in Zend_Session.

Zend_Session Configuration Options

Brett Bender
A: 

Just as a quick update to Brett Bender's answer. To get this to work I currently simply use:

Zend_Session::setOptions(array(
    'cookie_domain' => '.mydomain.com',
    'name' => 'MySessionNamespace',
));

I have this set in my bootstrap but it can be called anywhere before the session is started.

wiseguydigital