How do I check if a user is logged in?
-
I am writing a small JavaScript/PHP application that is not a WP plugin. The application stores options tied to the WP user id (because it is connected to my blog and I want to work with the existing accounts).
It checks if a WP user is logged in by calling wp_validate_auth_cookie(). This works BUT it also generates a lot of SQL on each call: 7 selects on wp_options, 1 delete on wp_options, 1 gigantic insert on wp_options. I uninstalled all plugins and restarted Apache but still see the problem.
This is the PHP I’m testing with
<?php // vvv CHANGE NEXT LINE TO POINT TO YOUR wp-config FILE vvv require_once getenv("DOCUMENT_ROOT")."/wp-config.php"; $userId = wp_validate_auth_cookie(); echo "USER: ".($userId?$userId:"no user"); ?>
Any ideas what could be going on?
- The topic ‘How do I check if a user is logged in?’ is closed to new replies.