Can't read cookie set by javascript in php
<?php
$messsage = $_COOKIE["textout"];
if($message != "") { echo $message; }
else { echo "Fail to read."; }
?>
You're saying $messsage = $_COOKIE["textout"]; , but on your IF your var is $message not $messsage.
Try:
<?php
$message = $_COOKIE["textout"];
if($message != "") { echo $message; }
else { echo "Fail to read."; }
?>
set cookie value in javascript and displaying it with php
i just changed the following
document.cookie='fcookie='+tempo;
and
if (isset($_COOKIE["fcookie"]))
echo $_COOKIE["fcookie"];
else
echo "Cookie Not Set";
Get/Read Javascript cookie with PHP
You can use $_COOKIE
, the superglobal. Just reference it like you would any array, where $_COOKIE['key_name']
is the cookie you want to access.
See the PHP API documentation.
PHP cannot read javascript cookies
<!DOCTYPE html>
<html>
<head>
<title>example</title>
<script type="text/javascript">
document.cookie = 'name=David' ;
</script>
</head>
<body>
<?php
var_dump($_COOKIE['name']);
?>
</body>
</html>
with this the cookie is set. Did you correct your Typo?
You wrote:
<?php
$encrIv = $_COOKIE['encrIv'];
echo $encriv;
?>
the correct way is to change the echo to
echo $encrIv;
or to change your variable to
$encriv = $_COOKIE['encrIv'];
EDIT:
Maybe your Problem is the not defined Path.
define a cookie like this:
document.cookie = 'sconName='+changedName+'; path=/'
Related Topics
How to Access Dynamic Variable Names in Twig
How to Find the First and Last Date in a Month Using PHP
How to Do Left Join in Doctrine
Pdo Prepared Statements With Wildcards
Wamp Cannot Access on Local Network 403 Forbidden
Group Array by Subarray Values
Prevent Sent Emails Treated as Junk Mails Using PHP Mail Function
Add a Custom Attribute to a Laravel/Eloquent Model on Load
MySQLi_Fetch_Array While Loop Columns
Intl Extension: Installing PHP_Intl.Dll
How to Emulate a Get Request Exactly Like a Web Browser
Fatal Error: Call to a Member Function Prepare() on Null
Use PHP to Set Cron Jobs in Windows
Parentheses Altering Semantics of Function Call Result