Ok, so i've been racking my brain trying to figure out how to get this to work.
What I've tried to do is tell the browser that "if" the cookie is set, then alert "you already at the cookie".
And if the cookie is NOT set, alert "the cookie hasn't been eaten" AND set the cookie afterwards.
What am I doing wrong?
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> eating cookies </title> <script type="text/javascript" src="jquery-1.2.6.min.js"></script> <script type="text/javascript" src="jquery.cookie.js"></script> <script type="text/javascript"> jQuery(document).ready(function($) { if ($.cookie('register') == 'yes') { alert("you already ate the cookie"); } else { if ($.cookie('register') != 'yes') { alert("cookie hasn't been eaten"); $.cookie('register', 'yes'); } }) </script> </head> <body> blah blah blah </body> </html>
Also, here's a demo page: http://www.eight7teen.com/DD/cookie-...okie-test.html



Reply With Quote

Bookmarks