gpt4 book ai didi

Php 无法读取安全 cookie

转载 作者:可可西里 更新时间:2023-11-01 13:19:12 25 4
gpt4 key购买 nike

PHP 无法读取安全 cookie。

代码(Javascript):

document.cookie = <?php echo '"'.$hCName.'="'; ?> + host + "; path=/; secure; HttpOnly";
document.cookie = <?php echo '"'.$uCName.'="'; ?> + username + "; path=/; secure; HttpOnly";
document.cookie = <?php echo '"'.$pCName.'="'; ?> + password + "; path=/; secure; HttpOnly";
document.cookie = <?php echo '"'.$dNCName.'="'; ?> + dbName + "; path=/; secure; HttpOnly";
document.cookie = <?php echo '"'.$dPCName.'="'; ?> + dbPort + "; path=/; secure; HttpOnly";

代码(PHP):

<?php
include_once("../scripts/session_start.php");
$host = $_COOKIE[$_SESSION['hCName']];
$username = $_COOKIE[$_SESSION['uCName']];
$password = $_COOKIE[$_SESSION['pCName']];
$dbName = $_COOKIE[$_SESSION['dNCName']];
$dbPort = $_COOKIE[$_SESSION['dPCName']];
echo "Host: ".$host.", Username: ".$username.", Password: ".$password.", dbName: ".$dbName.", dbPort: ".$dbPort;
?>

编辑:我得到:

Notice: Undefined index: hCName in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 3

Notice: Undefined index: in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 3

Notice: Undefined index: uCName in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 4

Notice: Undefined index: in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 4

Notice: Undefined index: pCName in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 5

Notice: Undefined index: in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 5

Notice: Undefined index: dNCName in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 6

Notice: Undefined index: in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 6

Notice: Undefined index: dPCName in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 7

Notice: Undefined index: in C:\Users\joonas\Desktop\Webon cms\root\install\createTables.php on line 7Host: , Username: , Password: , dbName: , dbPort:

最佳答案

两点:

  • 作为Scott Arciszewski指出,JavaScript 无法操纵 HTTP Only cookie。
  • 安全 cookie 仅在当前协议(protocol)为 HTTPS 时可用。

关于Php 无法读取安全 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31703866/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com