1

I'm trying to build a site that does not rely on the user enabling 3rd party cookies.

For some reason, I'm noticing null $_POST variables from a simple only in Firefox and Chrome when 3rd party cookies are blocked (IE is fine). This is only with POST. The GET variables from the same script store the data normally.

I have set IE privacy to "high" so that it "blocks all cookies without a privacy policy" and that still allows my POST data to work normally, probably because I have a privacy policy on every page.

And when I'm in FF or Chrome and uncheck "block 3rd party" cookies, then it's fine. I get the usual values I expect when I access $_POST['foo'].

Does anyone have a clue what may be going on and how to retrieve form data using POST in this situation? My code is below.

Thanks.

 <form id="submission" enctype="plain" name="submission" method="post" action="../index.php?pub_path=<?php echo $path;?>" >
  <input type="text" id="pubcomments" name="pubcomments" ></input>
  <input type="submit" id="postIt" value="Post to forum"></input>

index.php:

if (isset($_GET['pub_path'], $_POST['pubcomments'])) {

  $path = $_GET['pub_path'];  //shows the path

  $comment = $_POST['pubcomments']; // $comment is null


} 
skaffman
  • 398,947
  • 96
  • 818
  • 769
shellzie
  • 11
  • 1
  • 1
    This snippet doesn't involve cookies at all. Is there evidence your bug is cookie-related, or could it be purely coincidental? (Also, I don't think `plain` is a valid `enctype` value.) – zneak Aug 10 '10 at 22:02
  • What's with the `enctype=plain`? Can you show a full generated example of the form's `action` with the domain redacted out? – Pekka Aug 10 '10 at 22:10
  • What happens if you put *all* variables into the form (pub_path as a hidden input)? – Pekka Aug 10 '10 at 22:12
  • Load up HTTPFOX (it's in the Firefox Addons repository). It'll let you watch the requests go/come back and view the headers/bodies in there. Check and see if the post values are actually hitting the wire, or maybe getting dropped on the server. – Marc B Aug 11 '10 at 03:53
  • You may take a look here. [http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission/1282934#1282934][1] [1]: http://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission/1282934#1282934 – Raftalks Oct 19 '11 at 19:35

1 Answers1

0

Remove the invalid enctype - the browser does not know how to encode your variables and PHP does not know how to decode them.

The argument gets sent correctly as the request body in some browsers (you can see this with file_get_contents('php://input')) but the incorrect content type request header means that PHP will not decode the POST args into $_POST.

Cal
  • 7,067
  • 25
  • 28