开发者

null $_POST variables if 3rd party cookies blocked on FF & Chrome

开发者 https://www.devze.com 2023-01-11 04:42 出处:网络
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 simpleonly in Firefox and Chrome when 3rd party cook

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 i开发者_如何学Pythonn 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


} 


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消