I am probably missing something obvious but I haven't found a similar problem in the issue queue.
When I uncomment $cookie_domain = '.example.com'; (delete #) I get Access denied for user/1. I am able to get to login page, enter login and password and then fail.
As soon as I place that # back it works.
I am trying to let users stay logged when surfing subdomains.
I tried entering site's real name instead of example.com didn't work. Cleared browsers' (FF and Chrome) cashe - no vain.
I don't use any access restriction modules. But I enabled the 'Enforce
rules on adminstrators' - don't know if this can cause an issue.
BTW, I tried both on local and live server - similar results.
One thing I didn't edit httpd.conf on my local machine - it worked anyways, and i just can't edit it on my shared host live server. I can add subdomains on a live server as per docs' section with ease.
Structure is: example.com, sub.example.com, hub.example.com...

Comments

agentrickard’s picture

Component: - Domain Settings » Code

You might be getting bitten by #1189916: Login rejected on cached pages, but this is very odd behavior.

I think this entirely about cookie handling on the server, so the other settings are not relevant.

I wonder if your host is sending the proper $_SERVER['HTTP_HOST'] values on page requests? I would look at that first.

mefisto75’s picture

StatusFileSize
new1.03 KB
new1.24 KB
new997 bytes

Thank you for the continuos support.
I tried to understand what you suggested - new to all this.
Please, see the attached files.
1. "cookie_commented_out" is when I delete # before the string $cookie_domain - it's when user/1 can't login.
2. - with #, and after user/1 logged in.
3. - with # tag but user/1 didn't login. Could though.

Hope I am not confusing.

agentrickard’s picture

I think your problem is that you use 'localhost' for dev, so you are getting a cookie mismatch. See the referrer: http://localhost/drupal/user.

So of course you are logged out, because the site expects the cookie domain of 'localhost' and you return 'example.com'.

I test locally, and route example.com and subdomains to 127.0.0.1 so I don't have to use localhost.

See http://drupal.org/node/1096954 for more information.

On a Mac, I just edit /etc/hosts like so:

127.0.0.1	localhost
127.0.0.1 example.com
127.0.0.1 one.example.com
127.0.0.1 two.example.com
127.0.0.1 three.example.com
127.0.0.1 four.example.com
127.0.0.1 five.example.com
127.0.0.1 six.example.com
127.0.0.1 seven.example.com
127.0.0.1 eight.example.com
127.0.0.1 nine.example.com
127.0.0.1 ten.example.com
mefisto75’s picture

Ok, what I did.
On shared hosted site I edited settings.php so instead of $cookie_domain = '.example.com'; it reads $cookie_domain = '.mysite.com'; (site's actual name)
It worked! But extremely slow. Yet to find why.
On my local dev site. I changed $cookie_domain = '.example.com'; to $cookie_domain = '.localhost'; User/1 can login. Haven't tested with sub domains yet. Should work.
I am yet to find how to edit host file on my dev so I use '.example.com' instead of '.localhost'. I tried per your advice something went wrong and I am just too tired to keep trying - it's been several sleepless nights.
Must admit that most of my problems were/are due to misreading docs. So RTFM is the case again.
Thank you agentrickard i keep learning, it's never late, right?)

mefisto75’s picture

Status: Active » Closed (fixed)