title: WooCommerce WC()->session->get is not getting recognized
body: <p>We have created a site where a user enters a coupon code and it logs them in by creating a cookie by the name of <code>couponid</code>, then we save that cookie to the WooCommerce session because that cookie actually is the category id from which the products are displayed.</p>
  
  <p>Now sometimes the products get displayed, sometimes not, and whenever our custom cookie is set in the browser and we go to <code>/wp-admin</code> to login, it gives us the following error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function get() on a non-object</p>
  </blockquote>
  
  <p>The above error on the login screen of WordPress is coming from the following function in our <code>functions.php</code> file:</p>
  
  <pre><code>function gfc_insert_coupon_code_to_session(){
  
  if( 
      is_user_logged_in() 
      || ! array_key_exists( 'couponid', $_COOKIE ) 
      || WC()-&gt;session-&gt;get( 'couponid', 0 )
  ){
      return;
  }
  
  $couponID = esc_attr( $_COOKIE['couponid'] );
  
      if( $couponID ){
          WC()-&gt;session-&gt;set( 'couponid', $couponID );
      }
  }
  
  add_action( 'woocommerce_init', 'gfc_insert_coupon_code_to_session' );
  </code></pre>