title: Can't pass a session variable logging in with OpenID?
body: <p>I tried running this code which creates a SESSION variable for the Google email but for some reason the <code>$_SESSION['email']</code> does not want to store the data. I run the code and the only output I get after signing in with google is </p>
  
  <pre><code>hello world 1
  
  hello world 2
  
  &lt;?php
  
  session_start(); 
  
  require 'openid.php';
  $openid = new LightOpenID('http://www.splunk.com'); 
  
  if (!$openid-&gt;mode) 
  {
     $openid-&gt;identity = 'https://www.google.com/accounts/o8/id';
     $openid-&gt;required = array('contact/email');
     header('Location: ' . $openid-&gt;authUrl());
  } 
  else 
  {
     if ($openid-&gt;validate()) 
     {
        //echo "Hello World!";
        $attributes = $openid-&gt;getAttributes();
        $google_email = $attributes['contact/email'];
        $_SESSION['email'] = $google_email;
        echo $google_email."&lt;br /&gt;";
        echo "&lt;pre&gt;" . print_r($_GET, true) . "&lt;/pre&gt;";
        echo $_GET['contact_email'];
        header("Location: " . google_login.php);
  
     }
     else
     {
        echo '&lt;p&gt;hello world 1&lt;/p&gt;';
        echo "&lt;p&gt;". $_SESSION['email']. "&lt;/p&gt;";
        echo '&lt;p&gt;hello world 2&lt;/p&gt;';
     }
  }
  
  ?&gt;
  </code></pre>
  
  <p>I modified the above example with the google example from the <a href="https://gitorious.org/lightopenid" rel="nofollow"><code>LightOpenID</code> site</a> but now it doesn't validate for some reason.</p>
  
  <pre><code>&lt;?php
  # Logging in with Google accounts requires setting special identity, so this example shows how to do it.
  require 'openid.php';
  try 
  {
      # Change 'localhost' to your domain name.
      $openid = new LightOpenID('http://www.splunk.com');
      if(!$openid-&gt;mode) 
      {
          if(isset($_GET['login'])) 
          {
              $openid-&gt;identity = 'https://www.google.com/accounts/o8/id'; 
              $openid-&gt;required = array('contact/email');
              header('Location: ' . $openid-&gt;authUrl());
          }
  ?&gt;
  &lt;form action="?login" method="post"&gt;
      &lt;button&gt;Login with Google&lt;/button&gt;
  &lt;/form&gt;
  &lt;?php
      } 
      else if($openid-&gt;mode == 'cancel') 
      {
          echo 'User has canceled authentication!';
      } 
      else 
      {
          $attributes = $openid-&gt;getAttributes();
          $google_email = $attributes['contact/email'];
          echo $google_email;
          echo 'User ' . ($openid-&gt;validate() ? $openid-&gt;identity . ' has ' : 'has not ') . 'logged in.';
      }
  } catch(ErrorException $e) {
      echo $e-&gt;getMessage();
  }
  </code></pre>