Logging in from external PHP script and staying logged in
-
My requirement is to login the user into WP from an external PHP script and publish a post.
Once logged in, I would like the user to navigate to a regular wordpress page and not require to log in (manually) again.
Everything including the posting is working fine,-
except
when I open a new browser tab or navigate to a wordpress page from my PHP script the user is found not logged in.
I am using the following function to log in the user. What am I missing?function _my_user_login($username,$password) { $creds = array(); $creds['user_login'] = $username; $creds['user_password'] = $password; $creds['remember'] = true; $user = wp_signon( $creds, false ); wp_set_current_user($user->ID); wp_set_auth_cookie($user->ID, true); return $user; }
Thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Logging in from external PHP script and staying logged in’ is closed to new replies.