English 中文(简体)
为什么在吉大港山区应急措施开始的时候必须叫Cookie?
原标题:Why does SetCookie have to be called at the Beginning of an HTTP Response?

while reading about cookies i found difficulty to grasp the following statement
"setcookie() must be called before any output to the HTTP response. The main reason is that PHP is not buffering the HTTP response" please help me to interpret it in easy way

最佳回答

为了理解这一说法,你需要了解以下几个方面:

  1. HTTP responses consist of two parts, a set of "headers" (key-value pairs) and then the "body" which is the actual data e.g. a web page or image.
  2. HTTP headers have to be sent first, and once even one byte of the "body" has been sent, no more headers will be processed by the client.
  3. Cookies, among other things, are sent to the client in the form of HTTP headers.

因此,它说的是:除非你做一些特殊的事情,否则,你即刻的“echo”东西,或者在<外有任何数据? ......?>栏,PHP将用这些数据开始反应机构。 在这一点之后,再也不能派头脑,包括 co子制造头盔。

问题回答

这只是意味着,你需要确保所有头脑(ook通过吉大港山区的头盔确定)为产出 <>之前> 。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...