title: Saving Facebooks signed_request?
body: <p><strong>The situation</strong><br>
  I am playing around with the new Facebook iFrame tabs on pages. I am using the signed_request to get some facts about the app, the page and the user.</p>
  
  <p><strong>To challenge</strong><br>
  Facebook provides the signed_request params via $_REQUEST only on the first call of the iframe. The problem is to access the parms a second time e.g. for an ajax request.</p>
  
  <p><strong>This is how i did it</strong><br>
  I extended the PHP SDK like this to store the signed_request in a cookie.</p>
  
  <pre><code>/**
   * The name of the Cookie that contains the session.
   * @return String the cookie name
   */
  protected function getSessionSignedRequestCookieName() {
      return 'fbs_sr_' . $this-&gt;getAppId();
  }
  
  /**
   * Saves the signed_request as a browser coookie
   * @return void;
   */
  protected function saveSignedRequestAsCookie($signedRequest) {
      $cookieName = $this-&gt;getSessionSignedRequestCookieName();
  
      setcookie($cookieName, serialize($signedRequest));
  }
  
  /**
   * Returns the SigndRequest from $_COOKIE
   * @return array
   */
  public function getSignedRequestFromCookie() {
      $cookieName = $this-&gt;getSessionSignedRequestCookieName();
  
      if(isset($_COOKIE[$cookieName])) {
          $this-&gt;signedRequest = $_COOKIE[$cookieName];
          return unserialize($this-&gt;signedRequest);
      } else {
          return NULL;
      }
  }
  
  /**
   * Returns the data from a signed_request token provided by $_REQUEST or $_SESSION
   * @return array The decoede signed Request
   */
  public function getSignedRequest() {
      $signedRequest = parent::getSignedRequest();
  
      if($signedRequest != NULL) {
          $this-&gt;saveSignedRequestAsCookie($signedRequest);
          return $signedRequest;
      } else {
          return $this-&gt;getSignedRequestFromCookie();
      }
  }
  </code></pre>
  
  <p><em>What to you think</em>*
  I that a good idea or a bad workaround? Any suggestions/ improvements?</p>