Support » Fixing WordPress » Cookies and headers – logins sometimes failing

  • I’ve recently run into some really weird problems I’m having a hard time troubleshooting. The errors aren’t easily repeatable and not all users are reporting the same things. They started after a recent major template upgrade.

    The two main complaints are some users aren’t able to login and others aren’t being served the mobile version of the template. I’ve got no idea if the issues are related or what is causing them so I’ll just explain all the issues I can recall and maybe you guys can help me piece it together…

    I have a user login form on the front-end and most of the time it works. Sometimes it fails without an error, just reloads the page and the user finds themselves still logged out. Repeated attempts to login still won’t let the user in. I’ve found clearing the cookies will get rid of the issue, but asking a user to clear the cookies each time they want to login seems poor.

    The user DB is shared with an install of bbPress. As far as I know the issues aren’t occurring over there. At one time, months previous, I tried merging the cookies of the two installs (as detailed by a page on the bbPress site, right now the link eludes me) and failed. The user can login on either site, but they’ve gotta do it on a per site basis. I’ve got no idea if this somehow messed up the way my install of WP assigns cookies or something, thought I’d mention it.

    The other main issue is my mobile site sometimes fails to load. I’ve built the entire mobile site using the built in conditional is_iphone. The mobile site has been up for months with almost zero complaints. Somehow during the upgrade the functionality has become sketchy, with some users reporting the are repeatedly served the desktop version of the site on their mobile phone. During the relaunch of the new template almost all the edits were exclusively on the desktop site, I barely touched the mobile site and didn’t touch any of the conditionals. But somehow the is_phone check is now randomly failing.

    I’m almost completely at a loss as to how to troubleshoot these two issues. My phone is loading the mobile site without fail and everything looks perfect. In an attempt to try mobile detection other than the is_phone conditional I tried implementing the old standby script and was repeatedly served this error when trying to detect the browser:

    Warning: Cannot modify header information – headers already sent by (output started at /home/homeport/public_html/wp-content/themes/sandbox/header.php:5) in /home/homeport/public_html/wp-content/themes/sandbox/mobile_device_detect.php on line 109

    I’ve seen a similar error before in the past (on a different install) but I still don’t totally understand exactly what the header is or how/why it is sent and modified. Could there possibly be problems with the header that are affecting the login/cookies and mobile detection?

    Does anyone even have a small sniff of an idea where to start here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Another thing maybe worth mentioning: we are running WP Super Cache on the site and it’s added all sorts of stuff to the .htaccess file. In the latest version there are mobile options but I’ve got them off and I don’t have the rules in the .htaccess file. There is a clump of stuff in the .htaccess file I don’t recognize though, and one had the word header in it:

    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

    can someone tell me what that does or how it got there?

    We made a thread on our forums asking people to report when the mobile site failed to load and what browser they were using:

    After looking through some of the posts I’m even more confused. Lots of users who are having troubles have the same model phones as people who can load the site fine. Others have reported the site working, then not working. My fiancee’s phone wasn’t loading it for almost a day, then just started working last night.

    It appears to be almost completely at random. In a way, that makes me feel better, I might not have specifically broken something. But overall it just leaves me confused because I have no idea how to replicate the problem or where to look to fix it.

    The most pressing issue still remains the sporadic failure of the is_iphone conditional. Trying to pinpoint the problem, I made a blank template containing ONLY an is_phone check, and went about testing it on various devices. My template was setup like so:

    <?php if ( $is_iphone ) {?><h1>YOU ARE ON A MOBILE DEVICE</h1><?php } else { ?><h1>NOT</h1><?php } ?>

    On multiple devices that can’t load the mobile site (which uses is_phone), the test template worked just fine, rendering YOU ARE ON A MOBILE DEVICE. Checking the main index of the site, however, the devices are still served the desktop version.

    Anyone have any idea what exactly could be nerfing my is_phone checks? How could the conditional work in one template and not another, on the same device?


    Do you have any details on this conditional $is_iphone or $is_phone you’re talking about?? I couldn’t find any mention of it in the WP codex… nothing really showed up on a Google search either.

    One solution I’ve used is to check the browsers user agent and display whatever from this condition. something like:

    <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false) { ?>
    This IS an iPhone
    <?php } else { ?>
    This IS NOT an iPhone
    <?php } ?>

    But I would love to do this with a simpler native WP string if it exists…

    I still haven’t seen much info on the is_iphone conditional, I only discovered it on accident, as it’s used in the WP core.

    Here is a short article I wrote about using it:

    Everything seems to be working for me now. I probably should’ve updated this thread but last I looked no one had chimed in.

    I think we should start a movement to get is_iphone swapped to is_smartphone to include more browser agents. Right now it returns true for iphone and android but I’ve seen reports that it doesn’t work on BB or Palm.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Cookies and headers – logins sometimes failing’ is closed to new replies.