Search code examples
phpzend-frameworkhttp-redirectiframezend-acl

Iframe Integration - after session timeout redirect user to parent sites login page


I am working with another site (abcxyz.com) who is displaying the content of my site (mysite.com) to its users through iframe integration. The user logs in on abcxyz and has no idea abot mysite.com

Egs

So everything is working fine so far. Now when the session expires on my site - the user automatically gets redirected to my login page (mysite.com) within the iframe - So what they want is to redirect to their login page.

I am using Zend Frame work (PHP) and this is how I figured I will tackle this.

In my Zend_Acl class - in the predispatch method - I am checking for the referrer and if it matches abyxyz - i'm redirecting to their login page else mine

    if ($role == 'guest') 
    {               
        $referrer = $request->getHeader('referer');
        if (strpos($referrer,'abcxyz.com') !== false) {
            $redirector = new Zend_Controller_Action_Helper_Redirector();
            $redirector->gotoUrl('abcxyz.com/login.htm');
        }
        else {
            $request->setControllerName('user');
            $request->setActionName('login');
        }               
    }           

This does not seem to be working. It keep redirecting the user to my login page itself.

Is there anything wrong I am doing here or is there a better way to handle this

Please let me know

Thanks


Solution

  • The referer header is not very reliable. Even if it were, if the user is navigation your site, chances are that the referer is your own site.

    I don't know if javascript is an option, but there you can check if the current page matches the parent page and redirect if they don't (in your case). So you would have to serve your login page with a script that redirects to the other login page if the condition is not met.