Session through all subdomains and domain aliases.
1 2 3 4 56 7 8 9 1011 | $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); $options = $config->toArray(); if(! preg_match("/angeldesk.com$/iU", trim($_SERVER['HTTP_HOST']))) { $parts = explode('.', $_SERVER['HTTP_HOST']); $domain = '.' . $parts[count($parts) - 2] . '.' . $parts[count($parts) - 1]; $options['phpSettings']['session']['cookie_domain'] = $domain; } // Create application, bootstrap, and run$application = new Zend_Application(APPLICATION_ENV, $options); |
Comments
You must login before commenting on a snippet. If you do not have an account, please register.
Snippet description
There was task that every user has its own subdomain like http://feedback.angeldesk.com. AngelDesk is the base domain. feedback is a Zend routing variable 'customer'. In application INI I added
phpSettings.session.cookie_domain = ".angeldesk.com"
That solved the problem. Bat later we added posibility to bind external domain to account like for example http://support.mightyextensions.com which is equal to http://mightyextensions.angeldesk.com
The problem become to login to external domain. Session did not started there because cookie domain was always .angeldesk.com no matter what I did. And code above shows the only way it was possible to solve. It is to chnage public/index.php file.
* Change "/angeldesk.com$/iU" to your main domain.
Snippet details
- Created:
-
Sergey Romanov
- Edited:
-
Sergey Romanov
- Revision Id:
- 193
- Edit Message:
- Initial Release
- ZF Version
- 1.10.7
- Tags:
- session cookie_domain
- Comments:
- 0
- Views:
- 1880
- Points:
- 0 (0 votes)