Hi All,
I've started making some good progress developing for Contao and really enjoy it.
I've become stuck trying to allow a front end user to stay logged in across subdomains. The reason for this is that we have a multi-language site, each language on a different subdomain, and the checkout will be on another secure subdomain.
I've tried to extend FrontendUser so that I can override methods which call $this->setCookie, so that the domain can include subdomains.
i.e. change lines like this: (line 255)
Code:
$this->setCookie('FE_AUTO_LOGIN', $strToken, ($time + $GLOBALS['TL_CONFIG']['autologin']), $GLOBALS['TL_CONFIG']['websitePath']);
to:
Code:
$this->setCookie('FE_AUTO_LOGIN', $strToken, ($time + $GLOBALS['TL_CONFIG']['autologin']), $GLOBALS['TL_CONFIG']['websitePath'], ".mysite.com");
This seems to have problems of its own ( I have to override a lot of methods, from both FrontendUser and User)
And so far doesn't yet seem to be working as expected (not sure if its my dev environment setup)
But I can't help but wonder if there's another way to do this?
maybe a new TL_CONFIG setting?
$GLOBALS['TL_CONFIG']['cookieDomain'] = ".mysite.com";
and then the System.php file can be altered (line 513 onwards) (I don't think I can extend and replace System class through an extension?)
Code:
protected function setCookie($strName, $varValue, $intExpires, $strPath='', $strDomain=null, $blnSecure=null)
{
if (!strlen($strPath))
{
$strPath = '/';
}
$strDomain = $strDomain ? $strDomain : $GLOBALS['TL_CONFIG']['cookieDomain'];
setcookie($strName, $varValue, $intExpires, $strPath, $strDomain, $blnSecure);
}
Has anyone come across a solution to this?
Is it a totally bad idea to change System.php in this way?
Bookmarks