Login issues and $cookie_domain

This issue occasionally comes up when creating development instances of existing sites or during migrations, and since it's quite annoying yet painfully simple to solve, it's a nice little tip to share.

When migrating pre-existing Drupal sites from one environment to another, you may find yourself unable to log in, be it as the root admin (uid 1) or a generic user. You check the database, it's all there. So are the users, and the site shows up fine content-wise. Resetting your password ultimately brings you back to square one. What now?

Tirdad Chaharlengi, Senior Developer
#Drupal | Posted

This issue occasionally comes up when creating development instances of existing sites or during migrations, and since it's quite annoying yet painfully simple to solve, it's a nice little tip to share.

When migrating pre-existing Drupal sites from one environment to another, you may find yourself unable to log in, be it as the root admin (uid 1) or a generic user. You check the database, it's all there. So are the users, and the site shows up fine content-wise. Resetting your password ultimately brings you back to square one. What now?

Check if $cookie_domain didn't happen to be set in settings.php. This variable is not necessary unless you're working with multiple domains for the same site and would like to share a session cookie between them. In most cases where it was set, the old value (let's say yourolddomain.com) won't match your new environment's domain and that's why you won't be able to log into the site on yournewdomain.com. Commenting it out or updating it depending on your situation will fix the problem.

Tirdad Chaharlengi

Senior Developer