Index: sites/default/settings.php
===================================================================
RCS file: /cvs/drupal/drupal/sites/default/settings.php,v
retrieving revision 1.54
diff -u -p -r1.54 settings.php
--- sites/default/settings.php	28 Mar 2007 14:08:22 -0000	1.54
+++ sites/default/settings.php	23 Apr 2007 23:21:47 -0000
@@ -140,7 +140,7 @@ ini_set('url_rewriter.tags',        '');
  * We try to set the correct cookie domain.
  */
 if (isset($_SERVER['HTTP_HOST'])) {
-  $domain = '.'. preg_replace('`^www\.`', '', $_SERVER['HTTP_HOST']);
+  // strip www., IP addresses, and port numbers from HTTP_HOST
+  $domain = '.'. preg_replace('`(^www\.|[\d:\.]+$)`', '', $_SERVER['HTTP_HOST']);
   // Per RFC 2109, cookie domains must contain at least one dot other than the
   // first. For hosts such as 'localhost', we don't set a cookie domain.
   if (count(explode('.', $domain)) > 2) {
