Title: PHP warning on switch_to_olduser
Last modified: May 4, 2021

---

# PHP warning on switch_to_olduser

 *  Resolved [Ducktales](https://wordpress.org/support/users/ducktales/)
 * (@ducktales)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-on-switch_to_olduser/)
 * This happens on action ‘switch_to_olduser’
 * > ErrorException: Warning: Trying to access array offset on value of type bool
   > #
   > 8 /wp-content/plugins/user-switching/user-switching.php(128): user_switching::
   > remember […]
 * The relevant code starting at line 124.
 *     ```
       $current     = wp_parse_auth_cookie( '', 'logged_in' );
   
       // Here we calculate the expiration length of the current auth cookie and compare it to the default expiration.
       // If it's greater than this, then we know the user checked 'Remember Me' when they logged in.
       return ( ( $current['expiration'] - time() ) > $cookie_life );
       ```
   
 * The function `wp_parse_auth_cookie` can return a (bool) `false`. Then you can’t
   do an array lookup. Replacing `return` with `return $current &&` should do the
   trick.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-on-switch_to_olduser/#post-14430147)
 * Thanks for the report. I’ll get it fixed in the next version.
 *  Plugin Author [John Blackbourn](https://wordpress.org/support/users/johnbillion/)
 * (@johnbillion)
 * WordPress Core Developer
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-on-switch_to_olduser/#post-14431709)
 * Fixed in version 1.5.7.
 *  Thread Starter [Ducktales](https://wordpress.org/support/users/ducktales/)
 * (@ducktales)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-on-switch_to_olduser/#post-14432029)
 * Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP warning on switch_to_olduser’ is closed to new replies.

 * ![](https://ps.w.org/user-switching/assets/icon.svg?rev=3193956)
 * [User Switching](https://wordpress.org/plugins/user-switching/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-switching/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-switching/)
 * [Active Topics](https://wordpress.org/support/plugin/user-switching/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-switching/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-switching/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Ducktales](https://wordpress.org/support/users/ducktales/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/php-warning-on-switch_to_olduser/#post-14432029)
 * Status: resolved