title: Object to Cookie in PHP
body: <p>I am starting my studies in PHP and I'm having problems with an application:
  I need to put information of an object in PHP for a cookie and then receive a cookie to object again on another page.
  anyone has any solution to this problem?</p>
  
  <p>The information I want to store in cookie is just some information preferably Customer as background color, size of windows.</p>
  
  <pre><code>&lt;?php  
  class Client {    
  
  private $id;
  private $pSize;    
  private $color;
  
  function __construct($id) {
      $this-&gt;id = $id;
  }
  
  public function getPSize() {
      return $this-&gt;pSize;
  }
  
  public function setPSize($pSize) {
      $this-&gt;pSize = $pSize;
  }
  
  public function getColor() {
      return $this-&gt;color;
  }
  
  public function setColor($color) {
      $this-&gt;color = $color;
  }
  }
  ?&gt; 
  </code></pre>
  
  <p>In a page index.php i have:</p>
  
  <pre><code>&lt;?php      
    include_once 'Client.class.php';
      //Test Preference Client
      $client = new Client(1);
      $client-&gt;setColor("#000000");        
      $client-&gt;setPSize(200);       
  
      //using Serialize to put to Cookie
      $StringClient = serialize($client);
  
      //Store to Cookie
      $_COOKIE['PreferenceClient'] = $StringClient;
  </code></pre>
  
  <p>?></p>
  
  <p>In a another page i get the inrofmation:</p>
  
  <pre><code> if(isset($_COOKIE['PreferenceClient'])){
         // Unsing Unserialize to Object
          $objClient = unserialize($_COOKIE['PreferenceClient']);
  
          //Test data:
          echo $objClient-&gt;getColor();            
          //Continue with Performing changes to the client if the information exists...
      }
  </code></pre>
  
  <p><strong>I solved the problem. Thanks to everyone who helped.</strong>
  before i had tried only get the cookie information without serialize
  Guys, this is my first post, I apologize if I did something wrong.
  I have to make something up for you?</p>