title: Wordpress PHP Conflicting User Sessions
body: <p>I'm using the following function to programmatically login users via the frontend:  </p>
  
  <pre><code>    function auto_login() {
          $username = $_POST['user'];
          if ( !is_user_logged_in() ) {
              $user = get_userdatabylogin( $username );
              $user_id = $user-&gt;ID;
              wp_set_current_user( $user_id, $user_login );
              wp_set_auth_cookie( $user_id );
              do_action( 'wp_login', $user_login );
          }     
      }
      add_action('wp_ajax_auto_login', 'auto_login');
      add_action('wp_ajax_nopriv_auto_login', 'auto_login');
  </code></pre>
  
  <p>However one weird issue I've run into is the following scenario:</p>
  
  <pre><code>    1. User 1 logs in on PC 1
  
      2. User 1 email is displayed as logged in in PC 1
  
      3. User 2 logs in on PC 2
  
      4. User 1 email is displayed as logged in in PC 2
  </code></pre>
  
  <p>I think this might be due to conflicting sessions but I'm not sure. I've looked up on this for quite a few days on Google yet nothing really came up which helped me. </p>
  
  <p>So my question is, how do I solve this issue of conflicting sessions? </p>
  
  <p>Thanks</p>