PHP / JavaScript help

NSA

sudo apt-get thefuckout.tar.gz
Dec 9, 2011
715
86
Hello,

I am trying to set a PHP cookie by using:
PHP:
<?php $id = "?>data1<?php";
setcookie('id',$id,time() + (86400 * 7)); // 86400 = 1 day ?>

You see I try to set the cookie as a JavaScript variable... but when I echo the cookie I get:
"?>data1<?php" which is annoying.

I'm trying to get the last ID of a number of posts from a jquery get.
And what get's sent to the page is "52".

I need this so I can set "52" in a cookie so I can compare it with the other data.
So if data1 equaled "53" I could say "New Message"

If anyone can think of a better way of doing this, or provide me with a fix, it'd be really helpful!


Thanks.

EDIT: I'm using another way, but now, what get's returned from the jQuery "Get" is "False"

Here is my jQuery

function getID(){
$.get('getid.php', function(data1) {
if(data1 =! <?php echo $_COOKIE['id']; ?>){
alert("Different");
}else{
alert(data1 + "<?php echo $_COOKIE['id']; ?>");
}
});
}
 

Users who are viewing this thread

Top