By tsioukas on
I create on my server an subdomain like this app.example.com
The problem I want to load from index.php the logged user of example.com. So I write this
define('DRUPAL_ROOT', '/#path#/mypage/public_html');
require_once DRUPAL_ROOT.'/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
print_r($user);
When I run it from app.example.com/ and I am logged in main site works fine.
But when I am not logged in it loads the main drupal page.
Also when I try to load this page app.example.com/index.php?q=something and it loads my index.php not the drupal index even if a am not logged in.
Looks like, there is something when the drupal find root path, render everything for not authorized users.
Any solution?
Comments
Interesting.
Interesting.
I detect that when I clean the cache my code give me the user data normally even on anonymous users. But when I enter again into the main site, the problem appears again.
After a lot of play I uncheck the option "Cache pages for anonymous users" into Performance page.
Now I didn't do that again event if I check it.
I try to play with that more to detect exactly the config.
https://www.drupal.org/node
https://www.drupal.org/node/644164You can move the thread by editing the original post and choosing 'Post Installation' as the forum.Thank you.
Contact me to contract me for D7 -> D10/11 migrations.
Disabling Cache...
The only thing that I found and seams that it work is to disable cache (I try some modules but it doesn't work)
So if I add this on settings.php
but we don't want to disable total the cache so I made this trick to disable the cache based on problematic url
I know that is not the best solution but it seems that it works.
The Bug...
I detect the problem and the bug...
The bug is that somehow it get's data from cache because page app.example.com and www.example.com constuct same CID (ChacheID) on cache table.
app.example.com > cid = http://www.example.com
www.example.com > cid = http://www.example.com
Same on this
app.example.com/somepage > cid = http://www.example.com/somepage
www.example.com/somepage > cid = http://www.example.com/somepage
This is a bug. CID calculated from URI and it doesn't calculate the subdomain. Also somehow it puts full domain name (http://www.example.com) automatically example.com or www.example.com
I think that this must be fixed.