Jump to content

[SOLVED] Naming cookies with variables


Nexus Zero

Recommended Posts

My aim with this code is to prevent multiple votes on a single comment. I'm attempting to do this by adding an arrayed cookie that has a unique entry added each time a user votes. However, when I echo the following code

 

<?php 

$judgement = $_GET['j'];
$commentid = $_GET['cid'];

setcookie("cookie[$commentid]", $commentid);

?>

 

I get this error message: Notice: Undefined index: cookie[$commentid] in /home/fhlinux166/t/trivipedia.org/user/htdocs/judge.php on line 46

 

$commentid is a number, such as 1, 18 etc.

 

Does php have rules against this or am I doing it wrong?

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/62870-solved-naming-cookies-with-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.