Drupal Login Cookie

I noticed a weird issue when hosting multiple Drupal installations on the same domain, like a software company hosting all client demos on a single domain.
The scenario is: you will get kicked out from any installation as soon as you login to another.
I totally understand it's not a very common situation since the common is hosting all your sites from one code with multiple databases but I have mentioned the case this patch is targeting.

To cut it short, I managed to write these few lines that allow multiple logins to multiple Drupal installations on a single domain:
Simply add these lines near the end of your settings.php

if (isset($base_url)) {
$clean_base_url = str_replace('http://', '', $base_url);
$base_array = explode('/', $clean_base_url);
$cookie_domain = array_shift($base_array);
$cookie_path = implode('/', $base_array);
ini_set('session.cookie_domain', $cookie_domain);
ini_set('session.cookie_path', '/'.$cookie_path);
}

Note: Needless to say that you *should* have set $base_url above this block of code.
Hope This Helps.

Thanks

Thanks much for the information!

Submitted by Video (not verified) on 18 March 2008 - 11:54pm.
Sounds like it would be much

Sounds like it would be much easier with mutliple domains. Thanks for the info.

~Diego
www.ictsviluppo.it

Submitted by Anonymous on 26 June 2008 - 3:04pm.
Never would not have thought

Until that time I have not read about it

Submitted by Anonymous on 13 July 2008 - 7:39pm.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><p>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options