I've installed a fresh new drupal 5.0, everything was fine. But now whenever I log in, I get logged out as soon as I click any anchor link, at the first click.

What’s the problem?

Comments

jason342’s picture

Ok, I noticed that I'm only getting logged out when I click any home links.

Basically I get kicked whenever I go back to homepage via www.mysite.com.

So clicking a link that goes to www.mysite.com/contact is fine.

But when I click a home link or site name that directs to www.mysite.com, I get logged out.

rszrama’s picture

What are the URLs like before, during, and after you login? Is the base path the same?

i.e.: www.subdomain1.domain.com would generate a different cookie from subdomain1.domain.com. Then clicking a link that takes you to the other URL would make you appear to logout.

jason342’s picture

full URL, www.mysite.com, at all time. Only home links log me out.

pengume’s picture

It kept logging me out when I would click on a custom nav bar that had the links set to www.domain.com and the rest of site was domain.com fixed the links and it worked thanks!

jason342’s picture

Stupid FireFox (never thought I'd say that), things work fine in IE, but FF logs me out. But everything was working fine befoe!

ScarabMonkey’s picture

At first I could not login, so tried the 'forgot my password' thingy; the link I was sent did not log me in.

Now I find I cannot login at all in Firefox!

I only had a "user 1" and had stayed logged-in since first creation (earlier today)

Works fine in Opera.

rszrama’s picture

Holy crap! I just realized I had the same issue but figured it was something else. hehe I was using beta code and went to update my user.module... it was screwing up logins so I decided to roll back to the old module. So... I had an issue, too... I'm just not sure what was going on. Maybe it's a caching thing? This only happened when I tried to update an old site, not on a clean install. I was using FireFox, too... didn't try it with IE7 b/c I figured it was something with the update not the browser.

----------------------
Current Drupal project: http://www.ubercart.org

silverado’s picture

It happens to me too. I've installed a clean Drupal5 and I get logged out both with IE and FF. My PHP is 4.3.8.

How can I fix this?

Thanks

jason342’s picture

So whats the problem here? the database? Do I delete the install and make fresh install? Is something wrong with my drupal?

I don't have this problem with a test site, so that rules out FF being the main problem since I don't get logged out in FF with the test site.

silverado’s picture

No solution???

cog.rusty’s picture

So, what is the difference between your test site and your main site which has the problem?

- Any difference in the form of the URL? (subdomain or www or subdirectory?)
- Any other difference in their settings.php except the database. Any difference in their .htaccess file?
- Is the main site an upgrade from 4.7 or a fresh one?
- Have you been using the main site's domain for something else previously?

silverado’s picture

Mine is installed in a subdirectory. It's a fresh Druapl 5 installation. And I've altered the .htaccess file as said here http://drupal.org/node/9909

cog.rusty’s picture

That page refers to 4.5 and 4.6. Not sure if it those changes were ever needed, but I never needed them in 4.7 or 5.

cjyun103’s picture

I encountered similar problem, but my situation happens when I log in to two drupal sites at the same time. My friends and I built our sites under the same domain name:
www.mysite.com/A
www.mysite.com/B
www.mysite.com/C
.
.
.
As long as I log in at A site, I was immediately logged out at B site. This situation never happened with old drupals, and all of us have upgraded to 5.0 now. Occur on both IE and FF so probably not the browser's problem...

Please tell me how to solve this problem~Thanks!!

Jboo’s picture

This also happens to me with 4.7. I think the only thing i've changed recently is the htaccess, although it does only seem to happen in firefox.

My new EasySnoozing, Nursing and BusinessEgghead websites on D7!

cog.rusty’s picture

Is this a multisite with one Drupal installation and 3 separate settings directories under /sites? Or is it 3 separate Drupal installations?

Christoph C. Cemper’s picture

This problem appeared on a couple of 4.7 sites after switching from PHP 4.x to PHP 5.2.1

--- http://www.cemper.com
--- http://weblog.cemper.com
--- http://www.marketingfan.com

David N’s picture

I'm having the same problem, with users being logged out when clicking the "home" link. As soon as one clicks on any other link to any other page, they appear to be logged back in.

I'm using Drupal 5.1 (upgraded from 4.7) and PHP 5.2.2. Is there a solution for this?

VM’s picture

Troubleshooting FAQ's in the Handbooks provides : http://drupal.org/node/102114

David N’s picture

Thanks Kenn. I'll try adding that one line of code to the settings.php file.

This line from the handbook confuses me though: "For Drupal-5 beta testers; this has been resolved since the Beta-1 release." Maybe I understand it differently, but I thought an official release (5.1) would not have that problem.

David N’s picture

I added that line of code from the handbook, but it doesn't seem to have helped. I'm still being logged out of the site whenever I follow a link to the homepage. It seems to only occur in Firefox 2.0.0.4.

Anybody else still having this problem?

cog.rusty’s picture

Drupal 5.1 shouldn't need that fix. Since you upgraded and there has been a small change to how cookies are set, you may need to tell your users to clear their browser cookies for this one time and then to log in again. Try it yourself first to see if it solves the problem.

David N’s picture

Well the thing is, I have adjusted my settings in Firefox to clear the cache everytime the browser is closed. I've tried viewing the site on 3 computers at home and a few at work, and it frequently looks like I'm logged out, but there's no clear pattern. I can go to my homepage sometimes and not be logged out, while other times I'll manage to stay logged in. I've tried browsing different pages, and the frequency with which I am logged out varies every time.

I thought it was an issue with PHP5, so I asked my hosting company to recompile using PHP4, which they did tonight. No luck though, as the problem persists.

If anybody can help me out, I would appreciate it very much.

cog.rusty’s picture

Can you give any more details? I would check the following:

- How do you access your site? With www.yoursite.com or just yoursite.com or whichever? Perhaps some links contain www and some don't? Have you noticed if that makes any difference to your login problem or not?

- Is it any kind of multisite accessed as subdomain.yoursite.com or yoursite.com/subdirectory?

- Is your settings.php in the /sites/default directory or in a /sites/yoursite.com directory (if so, what exactly is the directory name)

- Does your settings.php contain a $base_url? In most cases (but not always) this is better left out (with a # in front), except if you have made sure that it conforms exactly with the URL which the user types.

- Near the end of your settings.php there are a few lines of code which set the cookie domain
to ".yoursite.com" (if it was yoursite.com or www.yoursite.com)
or to ".sub.yoursite.com" (if it was sub.yoursite.com)
You can replace those lines with something to set the cookie domain explicitly if you suspect that this is not ok (depending on the answers to the previous questions)

- Have you added any RewriteRule to your .htaccess which changes the URL which the user typed?

general need’s picture

This is driving me nuts. I am also logged out when I click on my Home link.

If I click any menu link I appar to be logged in again.

It is ONLY on my home page that I am apparently logged out – which is not even true as attempting to login gives me an access denied error and my name once again appears in my menu…. So I was never logged out in the first place, even though Drupal told me I was.

I am using Persistent Login which doesn’t appear to work any way, ie, my computer never remembers me.

Druplal 5.1
PHP 4.4.4

VM’s picture

There were fixes for this added to the Drupal 5.2 release, consider updating.

persistent login was also updated on August 19 to version 1.3, insure you are using the latest release.
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

general need’s picture

But no improvement.

Upgrading to 5.2 made me sweat a bucket of nerves, but I think I got it done. /admin/logs/status says I am using 5.2. However the update_status module still prompts me to update from 5.1. I may have to find a solution that that apparent problem separate to this logout issue.

VM’s picture

hard to help any further, without knowing specifically what you sites environment is. version of PHP ? have you gone through the Troubleshooting FAQ's section of the handbook with regards to login issues ?

have you cleared your browsers cookies ? and your databses sessions table ?
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

general need’s picture

PHP is 4.4.4I

According to the upgrade notes to 5.2 I have since attempted to edit my settings file to replicate my old customised settings.php but encountered problems and so decided to reverted back to my pre-upgrade
setting file and now I cant view my home page at all. But every other page is visible. Home page just produces a page not found error.

http://drupal.org/node/167367

"Second, the settings.php file has been modified due to a security hole. If you use a customized settings.php, be sure to compare lines 140 to 147 of the new file (v1.39.2.3) to your current settings.php."

VM’s picture

you should only use the new settings.php file and include the old db string. without knowing what else you modified for this "custom" settings file. it's difficult to help.
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

general need’s picture

Ok, I am only using the new setting file now and included the old db string.

I also am using the the htaccess file.Firefox is giving me this error:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete

* This problem can sometimes be caused by disabling or refusing to accept
cookies."

VM’s picture

Is firefox accepting cookies ? are your FF settings correct ? have you tried clearing your cookies ? clearing your sessions DB table ?
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

general need’s picture

After the mess created per my last post above this one I chose to re-wind the upgrade to 5.2 as best I could. admin/logs/status still states that I am using 5.2, I have no idea why. But at least I am able to now see all my website EXCEPT my home page, which simply returns a page not found error. It is worth noting that I no longer seem to have the logout issue when I return to the home page. I remain logged in (although I get page not found).

I don't think I will try and upgrade Drupal again for a very long time. :)

Ill just be happy if users can once again see my home page www.steepdeepjapan.com

ps - yes, FF is accepting cookies, I have cleared them all and the cache. I am in the process of working out how to clear the sessions table in my DB

general need’s picture

admin/settings/site-information didn't contain the word 'node' for default home page. Dont ask me why or how, but it didnt. All seems ok for now and I think I will live with the click Home = logout issue for the time being :)

cog.rusty’s picture

This is really messy, and updates to the database made by 5.2 update.php cannot be undone (if you actually ran update.php).

But if the front page is your only concern, notice that the "/node" page, Drupal's default front page, does work, so you could try something with the "Default front page" setting in the /admin/settings/site-information page.

general need’s picture

I did run update.php and per my above post one cause of the problem was the default home page as you suggest.As for upgrading, I don't really feel good about that and started another thread.

http://drupal.org/node/170532

VM’s picture

without updating your site to 5.2 you are open to hackers. just so you know. If your site gets hacked it will be much harder to get back from.

also unless you reversed your DB (with a backup you should have made of the DB) then your site is running a 5.2 DB on 5.1 files which may cause problems too.
_____________________________________________________________________________________________
give a person a fish and you feed them for a day but ... teach a person to fish and you feed them for a lifetime

general need’s picture

I appreciate the guidance and will heed your advice.

Although I will be adding the 5.2 files slowly and one at a time to better manage any negative impacts (mostly of my own making)

Marat’s picture

This is driving me nuts. I am also logged out when I click on my Home link.

If I click any menu link I appar to be logged in again.

It is ONLY on my home page that I am apparently logged out – which is not even true as attempting to login gives me an access denied error and my name once again appears in my menu…. So I was never logged out in the first place, even though Drupal told me I was.

This is the problem that I have ... any solution would be appreciated.

schorrie’s picture

Does anyone knows a solution for this problem,

i'm having it on my Drupal6 installation

jjones2008’s picture

I know this post is getting old, but I have a solution that may be useful, and wanted to share it on here in the event that anyone with the same issue may find it useful. The issue I see happen so often is when users are logged in to a Drupal website and click on certain links it would appear to log them out. A common reason for this for example would be accessing the website by typing http://example.com instead of http://www.example.com or vice versa. The issue occurs when the cookie domain for example would be set to say http://www.example.com and a user clicks on a link that is http://example.com it will not retain the cookie information and log them out. So the solution would be to change a line of code in settings.php and a couple of lines in .htaccess. First, choose when domain you will want to force people to use on you site which will be either http://www.example.com or http://example.com. In this example we will use http://example.com. Open your settings.php file which should be located in sites/default/ in your Drupal installation. Look for the this line of code

 # $cookie_domain = 'example.com';  

and remove the hash symbol and change example.com to your website name .com. This will set the cookie domain to http://example.com. Now to force users to use this new cookie domain regardless if the access your website using http://www.example.com we will modify the .htaccess file. Open the .htaccess file which should be located in the root or your Drupal installation, and look for this bit of code.

# If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

un-comment these two lines of code by removing the # hash symbols and enter your website name .com in place of the example.com.

# To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
   RewriteCond %{HTTP_HOST} ^www\.yourwebsitenamehere\.com$ [NC]
   RewriteRule ^(.*)$ http://yourwebsitenamehere.com/$1 [L,R=301]

That is all there is to it now no matter how people access your site they will always be forced to use the domain format of http://example.com and should not be logged out anymore.

*note to force users to user http://www.example.com set the cookie domain in settings.php to www.example.com and change this bit of code in the .htaccess file and change accordingly.

# To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
   RewriteCond %{HTTP_HOST} ^yourwebsitenamehere\.com$ [NC]
   RewriteRule ^(.*)$ http://www.yourwebsitenamehere.com/$1 [L,R=301]

I hope this helps and that someone finds it useful. Happy Coding.

Marko B’s picture

I dont understand this, i just updated from d 6.16 to .20 and drupal keeps getting me logged out. If this is the cas why isnt this already solved in drupal itself.

VM’s picture

Have you tried clearing the cookies stored by the browser?

Marko B’s picture

I tried lot of things. Opened a new post about this, seems i get logged out when i switch language, seems like cookie is not set how its supposed to when using multilang, but this appears from 6.16>
if nothing, i'll get back to 6.16 version.

cog.rusty’s picture

There have been changes in the handling of cookie_domain in 6.17. Read the release announcement page.

If you had a $cookie_domain = "example.com" line in settings.php in 6.16, now you will need to change it to $cookie_domain = ".example.com" (with a front dot) to get the same cookie behavior in 6.17 or newer.

If you had $cookie_domain = "www.example.com" in 6.16, you may need to change it to ".example.com" to get the same cookie behavior in 6.17 or newer.

Most people don't set any $cookie domain, so they don't have a problem (I think).

Marko B’s picture

I know about this . addon, as i said, tried many things. I use cookie as its needed for imce module. But even with that i get logged out when switching languages. I just checked and seems that when drupal adds cookie on this particular site no "DRUPAL_UID" is added to cookie for some reason. Maybe its some hosting problem alltogether?