0

Zend_Auth session not available while routing to sub domain but it is available other pages without subdomain until i logged out , following code i have used in ACL to route to sub domain. After logged in as example.com/index , while accessing like subdomain.example.com the already logged user's session or auth identity is not getting.

public function preDispatch(Zend_Controller_Request_Abstract $request) {
$module = $request->getModuleName();
$resource = $request->getControllerName();
$action = $request->getActionName();
$params = $request->getParams();

try {
    if (!$this->_acl->isAllowed(Zend_Registry::get('role'), $module . ':' . $resource, $action)) {
        $request->setModuleName('default')
                ->setControllerName('index')
                ->setActionName('login');

    } else {

        $subdomain = getSubDomainUrl();
        $params['username'] = $subdomain;
        //echo 'Role='.Zend_Registry::get('role').', Module='.$module . ', Resource=' . $resource. ', Action='. $action;

        if ($module == 'default' && $resource == 'index' && ($action == 'index'||$action == 'photography' || $action == 'album' || $action == 'photo-details' || $action == 'wedding-portfolio' || $action == 'wedding-album' || $action == 'wedding-photo-details') && isset($params['username'])&& $params['username'] != 'no') {
            $tblUsers = new Application_Model_DbTable_Users();
            $usr = $tblUsers->getUserDetailsByName($params['username']);

            if ($usr['memb_plan_id'] > 3) {
                if ($action == 'wedding-portfolio'||$action == 'index') {
                    $action = 'wedding-portfolio';
                    $params = array('sid' => $usr['id']);
                }
                $request->setModuleName('default')
                        ->setControllerName('index')
                        ->setActionName($action)
                        ->setParams($params);
            } else if ($usr['memb_plan_id'] >= 1 && $usr['memb_plan_id'] <= 3) {
                if ($action == 'index'||$action=='user-profile') {
                    $action = 'user-profile';
                    $params = array('sid' => $usr['id']);
                }
                $request->setModuleName('default')
                        ->setControllerName('index')
                        ->setActionName($action)
                        ->setParams($params);
            } else {
                throw new Zend_Controller_Action_Exception('This page does not exist', 404);
            }
        }

    }
} catch (Zend_Acl_Exception $e) {
    $request->setModuleName('default')
            ->setControllerName('index')
            ->setActionName('login');
}

}

  • why are you create a new question? It's the same that [this](http://stackoverflow.com/questions/22878328/zend-auth-session-not-available-while-routing-to-sub-domain) – doydoy44 Apr 05 '14 at 09:04
  • session generally doesn't work in sub domains. Try the link http://stackoverflow.com/questions/644920/allow-php-sessions-to-carry-over-to-subdomains – Amit Garg Apr 05 '14 at 09:10

0 Answers0