I have two servers, one is www.mydomain.com and the other is www2.mydomain.com. One of my primary menu items points to www2.mydomain.com.

I am using the following code in my page.tpl.php file to show the user they are logged in or to ask them to login:

<div id="navigation">
<?php global $user; ?>
<?php if ($user->uid) : ?>
Welcome Back <?php print $user_link ; ?> | <?php print l("logout","logout"); ?>
<?php else : ?>
<?php print l("Login/Register","user/login"); ?>
<?php endif; ?>
</div>

If a user who is logged in navigates to my www2.mydomain.com server, and then back to the www.mydomain.com server, it will show them the Login/Register message instead of their userlink. When they click on that to log back in, they get Access Denied, because they are in fact logged in.

The same thing happens any time a Google AdSense PSA is shown on my page. I have my AdSense set to show ads from an alternative URL rather than a Public Service Announcement. That URL is a static HTML page with an image and an href tag that acts as a house ad.

If a user hits a page and that static HTML is shown instead of a Google ad, they see the Login/Register message instead of the user_link.

Any idea what would cause such an issue?

Comments

ezra-g’s picture

Title: A really strange error » Incorrect user-specific information shown with AdSense ads

adding a descriptive title.

ezra-g’s picture

Status: Active » Closed (duplicate)

Actually, this seems like a duplicate of #577386: Authentication Persistence.

Jonah Ellison’s picture

Assigned: Unassigned » Jonah Ellison
Category: bug » support
Status: Closed (duplicate) » Active

Hmm, this may not be a duplicate, but rather a domain settings issue. The session and authcache cookies need to use the ".mydomain.com" domain (www2.mydomain.com is probably viewed as a separate domain). In your settings.php file, try adding:

ini_set('session.cookie_domain', '.mydomain.com')

to make the cookies work across subdomains.

Jonah Ellison’s picture

Status: Active » Closed (cannot reproduce)