I have a page, return.php. It has a line of HTML as follows:
<td><a href="#" dataP="<?= $partNumber[$x] ?>" onclick="popup(this)"><?= substr($avgCost[0],0,6) ?></a></td>
onclick, this calls the following popup function:
function popup(windowname) {
document.cookie = 'popupPartNumber='+windowname.getAttribute("dataP")+'; expires=Wed, 1 Jan 2070 13:47:11 UTC; path=/'
var x = document.cookie;
console.log(x);
windowname = 'popUpDiv';
blanket_size(windowname);
window_pos(windowname);
toggle('blanket');
toggle(windowname);
}
on this same page, this loads:
<div id="blanket" style="display:none;"></div>
<div id="popUpDiv" style="display:none;"">
<a href="#"" onclick="popup(this)"><img src="/img/close.png"></a>
<?php
$popupPartNumber = $_COOKIE['popupPartNumber'];
echo "<pre>";
echo htmlentities($_COOKIE['popupPartNumber'], 3, 'UTF-8');
//echo "cookie is: " . $_COOKIE['popupPartNumber'];
echo "</pre>";
?>
</div>
When I start this out and I click on the HTML link, I get a console.log output that says:
PHPSESSID=cvbt1gvisul27nccenaeum1hh0; popupPartNumber=123456789
but my php echo output says: null
Why is the cookie that I'm setting correctly in javascript not available to php?
Aucun commentaire:
Enregistrer un commentaire