Monday, August 22, 2022
HomeWordPress DevelopmentA number of points with Ajax login perform on account of browsers...

A number of points with Ajax login perform on account of browsers and cookies


Utilizing primary utilization of ajax login wordpress, no cookie wordpress_logged_in_ are created on safari and Chrome and firefox does not learn person when cookie “wordpress_logged_in”.

I’ve a number of subdomain that use identical theme. I’ve configured wp-config to have all cookie outlined on : “.web site.com” . Area and all subdomain get effectively identical cookies.

outline('ADMIN_COOKIE_PATH', '/wp-admin');
outline('COOKIE_DOMAIN', '.web site.com');
outline('COOKIEPATH', '.web site.com');
outline('SITECOOKIEPATH', '.web site.com');
outline('COOKIEHASH', md5('.web site.com') );

I additionally added outline ( ‘FORCE_SSL_ADMIN’ , true);

However I get solely these cookies (every generated by wp-admin and /wp-content/plugin):

  • wordpress_
  • wordpress_sec_

SAFARI :
I haven’t got wordpress_logged_in_ cookie solely on safari .
I’ve deleted all cache and cookies from safari browser however nothing helps.

CHROME and FIREFOX : I get effectively wordpress_logged_in_cookie.
However is_user_logged_in() return all the time “no”. nevertheless I can entry to wordpress dashboard with person logged in. However this perform work for me (admin)

My php code :

perform handle_user_login(){
    check_ajax_referer( 'ajax-login-nonce', 'safety' );
    
    $log_param = isset($_REQUEST['log-param'])?trim($_REQUEST['log-param']):"";
    if($log_param == "login_data" ){
        $data = array();
        $data['user_login'] = $_POST['user_login'];
        $data['user_password'] = $_POST['user_pass'];
        $data['remember'] = true;
        $person = get_user_by( 'login', $data['user_login']);
        
          $user_signon = wp_signon( $data, 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('standing'=>1, 'message'=>__('Login profitable, redirecting...')));
            }
        
    }
    wp_die();
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments