Index: includes/bootstrap.inc
===================================================================
--- includes/bootstrap.inc	(revision 6541)
+++ includes/bootstrap.inc	(working copy)
@@ -236,7 +236,17 @@ function conf_init() {
   global $db_url, $db_prefix, $base_url, $base_path, $base_root, $conf, $installed_profile;
   $conf = array();
   include_once './'. conf_path() .'/settings.php';
+  // don't re-calculate base_url, if done in settings.php
+  if (!isset($base_path)) {
+  	conf_base_url();
+  }
+}
 
+/**
+ * Sets the base URL correctly.
+ */
+function conf_base_url() {
+  global $base_url, $base_path, $base_root;
   if (isset($base_url)) {
     // Parse fixed base URL from settings.php.
     $parts = parse_url($base_url);
Index: sites/default/settings.php
===================================================================
--- sites/default/settings.php	(revision 6541)
+++ sites/default/settings.php	(working copy)
@@ -150,6 +150,14 @@ if (isset($_SERVER['HTTP_HOST'])) {
 }
 
 /**
+ * To prevent cookie collisions, use a unique session name. Session names only
+ * accept alphanumeric characters. If you want to share sessions across
+ * installations in the same domain, specify the session name by hand.
+ */
+conf_base_url();
+session_name(preg_replace("/[^a-zA-Z\d]/i", "", $base_url));
+
+/**
  * Variable overrides:
  *
  * To override specific entries in the 'variable' table for this site,
