I don't know why I have to enter my login info twice? Once when I enter, nothing happens. I still haven't logged in and I don't get any error message. Second time when I enter my login info I log in.

Also, when I logout I get the blank page and then I have to make page refresh in order to get the main page.

Comments

mertero’s picture

I'm having the same problems with my new Drupal site.

Any ideas what to do?

Ron Mertens
Metalgrass software

mertero’s picture

I tried searching for the solution... I found this -
http://drupal.org/node/55364

And applied the chanages to user.module but they didn't help.

This is very discouraging. I installed Drupal 4.6.0 and later upgraded to 4.7.0. Installed a few modules and made a few changes - but just very basic ones (I followed instructions from a Durpal book I have). How come such a basic thing is not working in a very basic installation??

Should I give up on Drupal and try some other CMS? Having to login twice (and sometimes even this doesn't work) is not a possibility for a real web site...

Ron Mertens
Metalgrass software

rryan’s picture

I've got a 4.7.1 install being used in a school for a school blogging project. I also have to have my users login twice to access resources. It is a pain.

Reggie Ryan

cmsproducer’s picture

There has been some talk about similar issues caused by anonymous cookies continuing to exist beyond the login stage.
http://drupal.org/node/55364

-----
iDonny - Web Content Management System Design, Development. & CRM

mertero’s picture

iDonny,

Thanks... I already made the patch you suggest in that page, but it didn't change anything (I updated the user.module file).

Any other ideas?

Ron Mertens
Metalgrass software

cmsproducer’s picture

In some situations (I have been told), regenerating the session ID at that point may not be enough and you should comment-out the three lines preceeding the function. That is:

Look for the login function (the one that you just tweaked), and comment the three lines before it as shown below:
(exclude the opening and closing PHP tags)


user_module_invoke('login', $form_values, $user);
// Some suggest silencing the next 3 lines as commented
// $old_session_id = session_id();
//  session_regenerate_id();
// db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id);
  }
}

function user_authenticate($name, $pass) {
  global $user;
  // Try to log in the user locally. Don't set $user unless successful.
  if ($account = user_load(array('name' => $name, 'pass' => $pass, 'status' => 1))) {
	session_regenerate_id(); //Create a new session just before login - also above 3 lines silenced
    $user = $account;
};

-----
iDonny - Web Content Management System Design, Development. & CRM

mertero’s picture

Danny,

Thanks again. I tried commenting those lines... It still happened to me. I had to login twice.

I've read that upgrading PHP might also help... I'll now wait for my hosting to go to PHP 5, maybe this will help?

I'll update this thread,

Ron Mertens
Metalgrass software

firec’s picture

Try turning off caching. It worked for me.

Stephen Winters’s picture

How do you turn off caching? Are you talking about turning off caching within drupal administer, or from the control panel of the website? Where would I go to turn off caching? How would I turn off caching if I can't log into my Drupal website?

Stephen
Winters Sewing
Winters Sewing: Upholstery Information Website

mertero’s picture

Guys,

I updated to PHP 5.1.4.

Now I can't login at all to any of my sites! Help!!!!!

No matter what I put in the login box (even if the user does not exist, or wrong password) I simply get the same page again (The main page).

What to do??

Ron Mertens
Metalgrass software

mertero’s picture

Fixed the logni problem - it was something to do with registerGlobal php settings.

However, the double login problem remains. I'm now using PHP 5 and MySQL 5. Any more ideas???

Ron Mertens
Metalgrass software

mertero’s picture

I found a fix. My problem was that my site was always directed to the non-www site.. i.e. :

www.mysite.com was directoed to site.com

And the login didn't take. A quick fix in the .htaccess file solved the problem.

Ron Mertens
Metalgrass software

mertero’s picture

I had a problem but it was solved. Is there some way to remove a comment if I do not want it anymore?

Ron.

jacksond’s picture

In the standard drupal .htaccess file, you have the option to allow users to use only the "www" URL or the non-www URL, but I don't see how you can get everyone who signs in at "www" to be redirected to the non-www URL, which is where the user login works. Can you tell me how to do this?

reggie75’s picture

http://www.cmsproducer.com/drupal-login-session-cookie-without-error

the author ahs posted a solutio on the drupal forums too, i forget where.

lambert-1’s picture

I tried the second of the two fixes (since it had appeared first), without result.

Then I added the first, AND IT WORKED!

No more double login! (And it also fixed the problem where "Create new account" would throw me back to the creation page -- after updating the database so pressing the Submit button again would not only give me the message that my confirmation email had been sent, it would throw an error that the email was already in the database...)

Turning the cache on or off made no difference.

I have already applied the "double cookie" fix in .htaccess to fix a previous class of login errors.

Thanks!

UPDATE FWIW, this problem showed up on FF 1.5.0.2 on OS X 10.4.7. Safari did not have the problem. I don't have Windows, so I don't know about Internet Exploder.

AstaC’s picture

Lambert.
What exactly did you do to fix the problem?
If you did a change in your htaccess - file couldn't you please copy the whole htaccess-file and show it here? Please?

iandickson’s picture

I just added the Front Page Mod to a 4.7.2 site and found I got double login issues.

Turning the mod OFF didn't solve, but leaving it on and making the default "node" did.

Firefox - B4 I installed FP, FF also had this issue, but other browsers (IE, Opera) didn't.

Ian Dickson - community specialist.
www.emint.org - Association of Online Community Professionals

reggie75’s picture

i set cookie lifetime to 0 (in sites/default/settings.php) so no cookie gets created on disk.

///ini_set('session.cookie_lifetime', 2000000);
ini_set('session.cookie_lifetime', 0);

this seems to have solved it for me.

the only drawback is when the user closes his browser, starts it again and comes back to the site, he is not logged in. (can pass it off as a feature :))

PS: You need to DELETE the OLD CREATED COOKIE after you do this, else it never lets you log in.
(in IE: Tools > Internet Options > Delete Cookies)
(in FF: Tools > Privacy > Cookies > Clear Cookies)

worked like a charm after that.

PPS: I also added the following line in settings.php,
but i dont think it would make any difference
ini_set('session.cookie_domain', '.domain.com');

where "domain" is your domain name.

Thanks,
Rajesh

abdu’s picture

For the second "Also, when I logout I get the blank page and then I have to make page refresh in order to get the main page."

I too experienced the same problem
it was because of some blank spaces (before and after the php tag )was there in template.php and i have removed that (theme directory), Now it's working

PWG’s picture

you wouldn't believe how happy your post made me. I've spent hours and hours on this and would have started chucking out modules en masse if I hadn't seen it. Many thanks.

Many grateful regards! :)

Petter

jschulz-1’s picture

Here's the code I used to get the cookie deleted upon user logout:


function mymodule_user($op, &$edit, &$user, $category = NULL) {
    
    switch ($op) {
        case 'logout':
	    sess_destroy_sid($user->sid);
            setcookie (session_name(), "", time() - 3600, "/", $_SERVER['HTTP_HOST'], 1);
	    session_regenerate_id();
            break;
    }

I had to specify the domain to the setcookie function before it would actually delete the cookie. The path wasn't sufficient I guess. The is using Drupal 5, but the code looks the same in D6 to me.