Support » Plugin: User Switching » User Switching fails after second time Switching to a user

  • Resolved uisneach


    The User Switching plugin generally works very well on my site.
    I have users with a Custom Role and I can switch to any of the users just fine and switch back to admin just fine.

    However, if I switch to a user a second time from Administrator, the user switching tries to work but I end up still showing as the Administrator with the message “switched to Administrator”. The only way I can get the user switching to work for that user, is to logout of WordPress, log back in as the Administrator and then do the user switching – it will work then, but of course it won’t work the second time I try it.

    I presume it is a cookie issue?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John Blackbourn


    WordPress Core Developer

    User Switching does support nested switching (in case you were wondering), so this should work fine.

    Can you try clearing all your cookies and trying again?

    Failing that, can you deactivate any other plugins on your site one by one and try again?

    Failing that, the only thing I can think of is that your auth cookie is getting truncated somewhere, possibly by a proxy, but I’m not sure how you would go about debugging that.

    I ran into the same problem and I found it persisted even with no other plugins enabled (and using the default theme). I tracked it down to the following lines in my .htaccess file:

    # Leverage Browser Caching by SG-Optimizer
    <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault                                      "access plus 6 months"
    # CSS
    ExpiresByType text/css                              "access plus 1 year"
    # HTML components (HTCs)
    ExpiresByType text/x-component                      "access plus 2 months"
    # HTML
    ExpiresByType text/html                             "access plus 6 months"
    # JavaScript
    ExpiresByType application/javascript                "access plus 1 year"
    ExpiresByType application/x-javascript              "access plus 1 year"
    # Manifest files
    ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
    ExpiresByType text/cache-manifest                   "access plus 0 seconds"
    # Media
    ExpiresByType audio/ogg                             "access plus 1 year"
    ExpiresByType image/gif                             "access plus 1 year"
    ExpiresByType image/jpg                             "access plus 1 year"
    ExpiresByType image/jpeg                            "access plus 1 year"
    ExpiresByType image/png                             "access plus 1 year"
    ExpiresByType image/svg                             "access plus 1 year"
    ExpiresByType image/svg+xml                         "access plus 1 year"
    ExpiresByType video/mp4                             "access plus 1 year"
    ExpiresByType video/ogg                             "access plus 1 year"
    ExpiresByType video/webm                            "access plus 1 year"
    ExpiresByType image/x-icon                          "access plus 1 year"
    ExpiresByType application/pdf                       "access plus 1 year"
    ExpiresByType application/x-shockwave-flash         "access plus 1 year"
    # Web feeds
    ExpiresByType application/atom+xml                  "access plus 1 hour"
    ExpiresByType application/rss+xml                   "access plus 1 hour"
    # Web fonts
    ExpiresByType application/font-woff                 "access plus 1 year"
    ExpiresByType application/font-woff2                "access plus 1 year"
    ExpiresByType application/         "access plus 1 year"
    ExpiresByType application/x-font-ttf                "access plus 1 year"
    ExpiresByType font/opentype                         "access plus 1 year"

    Removing those lines fixed the problem. I disabled SG Optimizer but it left those lines behind in my .htaccess file.

    Thread Starter uisneach


    Awesome joneiseman! I also was using SG Optimizer and that fixed the issue for me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘User Switching fails after second time Switching to a user’ is closed to new replies.