Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
PHP / JavaScript help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="NSA" data-source="post: 189896" data-attributes="member: 10034"><p>Hello,</p><p> </p><p>I am trying to set a PHP cookie by using:</p><p>[PHP]<?php $id = "?>data1<?php";</p><p>setcookie('id',$id,time() + (86400 * 7)); // 86400 = 1 day ?>[/PHP]</p><p> </p><p>You see I try to set the cookie as a JavaScript variable... but when I echo the cookie I get:</p><p>"?>data1<?php" which is annoying.</p><p> </p><p>I'm trying to get the last ID of a number of posts from a jquery get.</p><p>And what get's sent to the page is "52".</p><p> </p><p>I need this so I can set "52" in a cookie so I can compare it with the other data.</p><p>So if data1 equaled "53" I could say "New Message"</p><p> </p><p>If anyone can think of a better way of doing this, or provide me with a fix, it'd be really helpful!</p><p> </p><p> </p><p>Thanks.</p><p> </p><p>EDIT: I'm using another way, but now, what get's returned from the jQuery "Get" is "False" </p><p> </p><p>Here is my jQuery</p><p> </p><p>function getID(){</p><p>$.get('getid.php', function(data1) {</p><p>if(data1 =! <?php echo $_COOKIE['id']; ?>){</p><p>alert("Different");</p><p>}else{</p><p>alert(data1 + "<?php echo $_COOKIE['id']; ?>");</p><p>}</p><p>});</p><p>}</p></blockquote><p></p>
[QUOTE="NSA, post: 189896, member: 10034"] 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 ?>[/PHP] 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']; ?>"); } }); } [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
PHP / JavaScript help
Top