I have drupal installed running locally to test out things but when I upload
everything to my server I can't login on the server side to administer my drupal site
I reloaded the sql database and everything looks ok just can't login.

I also had this problem when I installed straight onto the server. It would let me create my initial user
but then it wouldn't let me login

Any suggestions?

Thanks

pete

Comments

Nick@usu-lug.org.ru’s picture

I have the same.
I moved my Drupal website to another hosting and now login don`t work.
I enter login & pass click 'Log In'... The page reload, but again login form on it (like I am not log in).
If enter wrong login or pass, "login incorrect" messge (so login&pass check works well).
My browser allow coockies and I can see my Drupal site coockie.
(I tried another browser too)
Remote login on other sites (via drupal.module) works well (you can see it).

Locally (on my workstation) everething works fine.
If install new Drupal to hosting everething works fine (but I wanna save my content).

I`ve tried to switch off cache $conf['cache'] = 0 to conf.php or 'UPDATE variable SET value = 's:1:"0";' WHERE name = 'cache'; (is it right?)
but login still don`t work.

I`ve tried to switch off clean urls, but nothing change.

:(

--
Sorry for my english.

sepeck’s picture

have you updated the base_url in conf.php?
and you generally want to keep clean url's off until the site is working properly.

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Nick@usu-lug.org.ru’s picture

No, but url not changed (DNS record changed).

sepeck’s picture

is it posible that the dns change had not replicated to your new server yet?

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Nick@usu-lug.org.ru’s picture

No.. DNS ok.

See http://drupal.org/node/14939#comment-24202.
I`ve solved the problem.

Nick@usu-lug.org.ru’s picture

I`ve changed in includes/session.inc
in function sess_write($key, $value) {

db_query("UPDATE {sessions} SET uid = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $_SERVER["REMOTE_ADDR"], $value, time(), $key);

to

db_query("UPDATE {sessions} SET uid = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid like '%s'", $user->uid, $_SERVER["REMOTE_ADDR"], $value, time(), $key);

(line 48 in my session.inc)
and now login works!

Original query doesn`t works:

mysql> select * from sessions where uid=8;

+-----+----------------------------------+---------------+------------+-----------------+
| uid | sid                              | hostname      | timestamp  | session         |
+-----+----------------------------------+---------------+------------+-----------------+
|   8 | 46426475df637bf332c1e7a0f2025525 | 1.1.1.1    | 1104582292 | messages|a:0:{} |
+-----+----------------------------------+---------------+------------+-----------------+
1 row in set (0.00 sec)

mysql> UPDATE sessions SET uid = 8, hostname = '1.1.1.1', session = 'messages|a:0:{}', timestamp = 1104582292 WHERE sid = '46426475df637bf332c1e7a0f2025525';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0

(hostname changed)

I don`t know why '=' don`t works :( any ideas? mysticism...

p.s.

mysql> select * from sessions where sid='46426475df637bf332c1e7a0f2025525';

+-----+----------------------------------+---------------+------------+-----------------+
| uid | sid                              | hostname      | timestamp  | session         |
+-----+----------------------------------+---------------+------------+-----------------+
|   8 | 46426475df637bf332c1e7a0f2025525 | 1.1.1.1 | 1104582292 | messages|a:0:{} |
+-----+----------------------------------+---------------+------------+-----------------+
1 row in set (0.00 sec)
adolg’s picture

Had this problem in Mozilla only (Gecko/20060111 Firefox/1.5.0.1), not in IE 6.0 with Drupal 4.6.3 - I wonder if it's fixed in 4.7? Your suggested fix worked for me, thanks!

mountain girl’s picture

hi Nick,

since upgrading to 4.7 i've had the problem that goes:
login on front page, hit login > front page rerenders as if i have not logged in > login again > login successful

meanwhile, the user has actually logged in twice and therefore has two sessions running concurrently.
this applys to all users. happens on mozilla and ie

i opened up the includes/sessions.inc file, but it is quite different to the earlier version.

any ideas on alternative fixits?

giorgosk’s picture

take a look at http://drupal.org/node/6696
and http://drupal.org/node/60584

my solution was to disable cache in the admin > settings > cache
as none of the patches I found worked
(I kept getting those "Headers already sent" messages)
I guess something is wrong in the caching mechanism.

--
chios sightseeings

------
GiorgosK
Web Development

boza’s picture

Great! It works and login!

Trouble was after that, when I first backup full database through one version of phpmyadmin, and then restored this database throught the other version of phpmyadmin. May be, that was the case.

who can be think, that SIDs become wrong? :-)

Michael Boza from Saratov, Russia http://www.boza.ru

Wojtek Kruszewski’s picture

The solution works also for me!

Ubuntu Edgy, Apache/2.0.55, Drupal 5.1.

Problem arrived after setting up Virtual Hosts:
Listen 8082
NameVirtualHost moak:8082
<VirtualHost moak:8082>

...and was resolved by adding "like" to session.inc

Many thanks!

Wojtek Kruszewski’s picture

On another box with similar setup adding "LIKE" to the query in sessions.inc didn't work. What DID work was to comment out section in settings.php that sets cookie domain:
//ini_set('session.cookie_domain', $domain);

robrepp’s picture

I'm on a LAN with my Drupal 5.1 on Ubuntu 7.04 Feisty LAMP server running Apache2/PHP 5. I had opened a hole in the firewall forwarding port 9900 to port 80 on the Drupal server. LAN users could log in, but remote users could not (they'd go from http://main.url.com to http://main.url.com/node and be presented with the login page again). Looks like the $domain value was being set for the LAN and messing up pages for the remote users. Commenting this out seems to have resolved the issue (although not sure what I may have broken by doing this...).

Thanks, Wojtek!

plong0’s picture

Worked for me as well! Thanks so much for this!

weedoo’s picture

Ok I had the exact same problem. What I did was move my data from local to server and same thing for DB, then this issue took all my time. I had to read most post about it and what solved my problem was easy

I tried this method first http://drupal.org/node/14939#comment-24202, it worked but I don't like to play in drupal core so I realised I only had to do the following,

1.(maybe) logout from admin first, if for some reason you are logged in
2.Clear all drupal cache + sessions table
3.Clear browser cookie + cache
4.Restart browser

Worked for me, hope it can help someone

btw, I am using Drupal 5.1

FableForge’s picture

Many thanks!
P.S. I tried no other solution listed in all the many threads about this issue, I figured I would try those for last if this one didnt work. It did. Thank you!

madhattertech’s picture

I had the same problem where If i entered in an incorrect username, I would get an error message.

However, if I used a correct username / pw combo, the page would reload with an "You are not authorized to access this page" message.

I finally figured out that the cookie_domain in settings.php was set. I commented out that line, and I could once again log in.

# $cookie_domain = 'example.com';

m.anoune’s picture

Thank you, I had the same problem and your solution worked fine for me.