Using basic usage of ajax login wordpress, no cookie wordpress_logged_in_ are created on safari and Chrome and firefox doesn't read user when cookie "wordpress_logged_in".
I have several subdomain that use same theme. I have configured wp-config to have all cookie defined on : ".website.com" . Domain and all subdomain get well same cookies.
define('ADMIN_COOKIE_PATH', '/wp-admin');
define('COOKIE_DOMAIN', '.website.com');
define('COOKIEPATH', '.website.com');
define('SITECOOKIEPATH', '.website.com');
define('COOKIEHASH', md5('.website.com') );
I also added define ( 'FORCE_SSL_ADMIN' , true);
But I get only these cookies (each generated by wp-admin
and /wp-content/plugin
):
- wordpress_
- wordpress_sec_
SAFARI : I don't have wordpress_logged_in_ cookie only on safari . I have deleted all cache and cookies from safari browser but nothing helps.
CHROME and FIREFOX : I get well wordpress_logged_in_cookie. But is_user_logged_in() return always "no". however I can access to wordpress dashboard with user logged in. But this function work for me (admin)
My php code :
function handle_user_login(){
check_ajax_referer( 'ajax-login-nonce', 'security' );
$log_param = isset($_REQUEST['log-param'])?trim($_REQUEST['log-param']):"";
if($log_param == "login_data" ){
$info = array();
$info['user_login'] = $_POST['user_login'];
$info['user_password'] = $_POST['user_pass'];
$info['remember'] = true;
$user = get_user_by( 'login', $info['user_login']);
$user_signon = wp_signon( $info, false );
if ( !is_wp_error($user_signon) ){
clean_user_cache($user_signon->ID);
wp_set_current_user($user_signon->ID);
wp_set_auth_cookie($user_signon->ID, true, is_ssl());
update_user_caches($user_signon->ID);
echo json_encode(array('status'=>1, 'message'=>__('Login successful, redirecting...')));
}
}
wp_die();
}