Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 阻止cookie获取其他页面?_Php_Security_Cookies - Fatal编程技术网

Php 阻止cookie获取其他页面?

Php 阻止cookie获取其他页面?,php,security,cookies,Php,Security,Cookies,我不想允许从其他页面获取cookie!我在互联网上被搜索过,但并没有真正找到,或者我不知道如何提及那个案例。我该如何处理这个问题!我想在test2.php中获取null,但在test.php中获取cookie test.php <?php setcookie("acc_id", "23A", time() + 3600, '/'); header("test.php"); var_dump($_COOKIE); // 'acc_id' => string '23A' (length=

我不想允许从其他页面获取cookie!我在互联网上被搜索过,但并没有真正找到,或者我不知道如何提及那个案例。我该如何处理这个问题!我想在
test2.php
中获取null,但在
test.php
中获取cookie

test.php

<?php
setcookie("acc_id", "23A", time() + 3600, '/');
header("test.php");
var_dump($_COOKIE); // 'acc_id' => string '23A' (length=3)
?>
<?php
var_dump($_COOKIE); // 'acc_id' => string '23A' (length=3)

test2.php

<?php
setcookie("acc_id", "23A", time() + 3600, '/');
header("test.php");
var_dump($_COOKIE); // 'acc_id' => string '23A' (length=3)
?>
<?php
var_dump($_COOKIE); // 'acc_id' => string '23A' (length=3)

您可以在setcookie语法中使用
$path
参数

setcookie(“acc_id”,“23A”,time()+3600,/test.php”)

现在,如果您尝试打印($\u COOKIE['acc\u id'])从test2.php中,它将显示未定义的索引,这意味着没有为该页面设置cookie


…那么不要在
test2.php
中调用
$\u COOKIE
?你为什么不想把它带过去?这就扼杀了COOKIE的设计目的。可能是