Avoid the problem
It will work but will cause session problem, [...] when I logout on flat.com, if I go to www.flat.com
Having an application which responds to multiple hostnames can be problematic, and is best avoided. The easiest solution to that problem, is to ensure that there is only one domain in use for the application
For example using apache add the following to the webroot .htaccess file:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
Or using nginx add a server block like so:
server {
listen 80;
# listen on the www host
server_name www.example.com;
# and redirect to the non-www host
return 301 $scheme://example.com$request_uri;
}
Or just define the constant on the cli
Alternatively, conditionally define the constant in your bootstrap file:
if (php_sapi_name() === 'cli') {
define('FULL_BASE_URL', 'http://example.com');
}