title: How can I access POST data and then delete it in CakePHP?
body: <p>I am building an Android application which connects to my remote server. I am allowing users to add new things but they must also be authenticated before they are allowed to add. Here is an example of what they add:</p>
  
  <pre><code>List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
  params.add(new BasicNameValuePair(SharedVariables.TAG_NAME, name));
  params.add(new BasicNameValuePair(SharedVariables.TAG_ADDRESS, address));
  params.add(new BasicNameValuePair(SharedVariables.TAG_TYPE, type));
  params.add(new BasicNameValuePair(SharedVariables.TAG_DESCRIPTION, description));
  params.add(new BasicNameValuePair(SharedVariables.TAG_DIFFICULTY, difficulty));
  params.add(new BasicNameValuePair(SharedVariables.TAG_TERRAIN, terrain));
  params.add(new BasicNameValuePair(SharedVariables.TAG_LONG, Double.toString(currentLng)));
  params.add(new BasicNameValuePair(SharedVariables.TAG_LAT, Double.toString(currentLat)));
  params.add(new BasicNameValuePair(SharedVariables.TAG_UID, Integer.toString(2)));
  
  //Retrieve hash and id to identify authenticate user
  UserAuth auth = new UserAuth(AddSpot.this);
  HashMap&lt;String,String&gt; session = auth.getUserDetails();
  params.add(new BasicNameValuePair(SharedVariables.TAG_UID, session.get("id")));
  params.add(new BasicNameValuePair(SharedVariables.TAG_HASH, session.get("hash")));
  </code></pre>
  
  <p>As you can see, in the first part, I am storing the things the user is adding themselves, however, I then also pass on the user id and then the token/hash into the POST data as can be seen in the last part. My problem is, I don't want to add everything into the database table with <code>$this-&gt;Location-&gt;save($this-&gt;request-&gt;data)</code>. Instead I want to be able to pick out the user id and the hash and remove it and then save it all the other stuff. How can I do this in CakePHP?</p>
  
  <p>This is my method in CakePHP right now:</p>
  
  <pre><code>function add()
  {               
      if ($this-&gt;request-&gt;is('post'))
      {
          $response = array();
          $this-&gt;loadModel('User');
          if($this-&gt;User-&gt;validateHash($id, $hash))
          {   
              //Do some logic to remove id and hash from request
  
              $this-&gt;Location-&gt;create();
              //Save data from POST
              if ($this-&gt;Location-&gt;save($this-&gt;request-&gt;data))
              {
                  //Successfully saved
                  $this-&gt;response-&gt;statusCode(200);
              } 
              else
              {
                  //Error in saving
                  $this-&gt;response-&gt;statusCode(500);
              }
          }
          else 
          {
              //Does their hash match? No, then they are unauthorized to add
              $this-&gt;response-&gt;statusCode(401);
          }
      }
      $this-&gt;set(compact('response'));
      $this-&gt;set('_serialize', array('response'));
  }
  </code></pre>