Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php cannot read secure cookies

Php cannot read secure cookies.

Code(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";

Code(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;
?>

Edit: I am getting:

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 7 Host: , Username: , Password: , dbName: , dbPort:

like image 328
Jojo01 Avatar asked Jul 29 '15 14:07

Jojo01


1 Answers

Two points:

  • As Scott Arciszewski points out, HTTP Only cookies cannot be manipulated by JavaScript.
  • Secure cookies are only available when the current protocol is HTTPS.
like image 128
SilverlightFox Avatar answered Sep 22 '22 13:09

SilverlightFox