Zend_Auth and subdomains

I was working today on an user authentication system that redirects the users to their own sub-domain after a successful login. It should work like this: user comes to www.exmple.com, fills in his credentials and after successful login he/she should be redirected to username.example.com. All fine and dandy except the session is not persistent between sub-domains of example.com. After a bit of google and some help from eXcuvator on #zftalk, i found the solution:

Just put the following in your Bootstrap.php and everything should just work:

    protected function _initSession()

        Zend_Session::setOptions( array('cookie_domain' => '.example.com', 'use_only_cookies' => true, 'name' => 'yourSessionName'));

Leave a Reply

Your email address will not be published. Required fields are marked *