I want to Auto login to my wordpress admin to perform some Actions so i used snoopy php class for this. My sample code is here
<?php
include 'Snoopy.class.php';
$snoopy = new Snoopy;
$submit_url = "http://localhost/wordpress/wp-login.php";
$submit_vars["log"] = "admin"; //username
$submit_vars["pwd"] = "admin"; //password
$submit_vars["rememberme"] = "forever";
$submit_vars["redirect_to"] = "http://localhost/wordpress/wp-admin/";
$submit_vars["testcookie"] = "1";
$submit_vars["wp_submit"] = "submit";
$snoopy->submit($submit_url,$submit_vars);
print $snoopy->results;
?>
But I'm getting:
ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
Though, I can login manually but this isn't working and cookies are also enabled in my browser.
What i'm doing wrong? and how can i make this to work ?
Print the header:
print_r ($snoopy->headers);
Output:
... [5] => Set-Cookie: wordpress_test_cookie=WP+Cookie+check; ...
But print the cookies
print_r ($snoopy->cookies);
delivers
... [wordpress_test_cookie] => WP Cookie check ...
Solution: Set
$snoopy->cookies['wordpress_test_cookie']="WP+Cookie+check";
manually before submit, because Snoopy clear the cookie content in plaintext and set the "+" in whitespace.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.