title: google plus login api cookie
body: <p>I am using google app engine python. I followed the example code to let user login. After this step am I supposed to create my own cookie or session to remember the user? Because when i refresh the page, the login button appears again.</p>
  
  <p>This is the javascript.</p>
  
  <pre><code>&lt;script src="https://apis.google.com/js/plusone.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
    /*
     * Triggered when the accepts the the sign in, cancels, or closes the
     * authorization dialog.
     */
    function loginFinishedCallback(authResult) {
      if (authResult) {
        if (authResult['error'] == undefined){
          gapi.auth.setToken(authResult); // Store the returned token.
          toggleElement('signin-button'); // Hide the sign in upon successful sign in.
          getEmail();                     // Trigger request to get the email address.
        } else {
          console.log('An error occurred');
        }
      } else {
        console.log('Empty authResult');  // Something went wrong
      }
    }
  
    /*
     * Initiates the request to the userinfo endpoint to get the user's email
     * address. This function relies on the gapi.auth.setToken containing a valid
     * OAuth access token.
     *
     * When the request completes, the getEmailCallback is triggered and passed
     * the result of the request.
     */
  
    function getEmail(){
      // Load the oauth2 libraries to enable the userinfo methods.
      gapi.client.load('oauth2', 'v2', function() {
            var request = gapi.client.oauth2.userinfo.get();
            request.execute(getEmailCallback);
          });
    }
  
    function getEmailCallback(obj){
      var el = document.getElementById('email');
      var email = '';
  
      if (obj['email']) {
        email = 'Email: ' + obj['email'];
      }
  
      //console.log(obj);   // Uncomment to inspect the full object.
  
      el.innerHTML = email;
      toggleElement('email');
    }
  
    function toggleElement(id) {
      var el = document.getElementById(id);
      if (el.getAttribute('class') == 'hide') {
        el.setAttribute('class', 'show');
      } else {
        el.setAttribute('class', 'hide');
      }
    }
    &lt;/script&gt;
  </code></pre>
  
  <p>This is the login button.</p>
  
  <pre><code>&lt;span id="signin-button" class="show"&gt;
           &lt;div class="g-signin" data-callback="loginFinishedCallback"
            data-approvalprompt="force"
            data-clientid="279937419542.apps.googleusercontent.com"
            data-scope="https://www.googleapis.com/auth/plus.login 
            https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me                            https://www.googleapis.com/auth/userinfo.profile"
            data-height="short"
            data-cookiepolicy="single_host_origin"
                &gt;
          &lt;/div&gt;
      &lt;/span&gt;
  </code></pre>